PDA

View Full Version : HELP--PHP--HELP



paul
08-21-2003, 05:32 PM
I really need help with my php settings. I am having problems with php_self and the values returned from the westhost server to ie6. The source should be:


<form action="?" method="POST" name="snackoForm" id="snackoForm">

and I'm getting:


<form action="acko/snacko/register_snacko.php?"[/color] method="POST" name="snackoForm" id="snackoForm">

Does anyone have any ideas????

The source works fine on my test server (win98/Abyss Web Server) but not on the WestHost server. Here is the code:


<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO snacko (rank_title, first_name, last_name, callsign, sq_name, email, password) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['rank_title'], "text"),
GetSQLValueString($HTTP_POST_VARS['first_name'], "text"),
GetSQLValueString($HTTP_POST_VARS['last_name'], "text"),
GetSQLValueString($HTTP_POST_VARS['callsign'], "text"),
GetSQLValueString($HTTP_POST_VARS['sq_name'], "text"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['password'], "text"));

mysql_select_db($database_connSupersnacko, $connSupersnacko);
$Result1 = mysql_query($insertSQL, $connSupersnacko) or die(mysql_error());

$insertGoTo = "/snacko/test_confirm.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>

<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Rank/Title</td>
<td><input type="text" name="rank_title" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">First Name</td>
<td><input type="text" name="first_name" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Last Name</td>
<td><input type="text" name="last_name" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Callsign</td>
<td><input type="text" name="callsign" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Squadron</td>
<td><input type="text" name="sq_name" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email</td>
<td><input type="text" name="email" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password</td>
<td><input type="text" name="password" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&</td>
<td><input name="Submit" type="submit" id="Submit" value="Submit">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>

FZ
08-22-2003, 07:40 PM
I think the whole point of PHP_SELF is to point to the file "being executed", so what it is doing now seems to be correct. If all you wanted was a ? to appear, then you should just type the ? yourself instead of using PHP_SELF. Also, I believe the way you are doing a lot of the stuff in your coding is for older versions of PHP, not 4.3.x which WestHost has installed...

Personally, I wouldn't pass values using both GET and POST as it gets really messy in the code (which is evident here!)... I think you should rather store the variables passed by the query string into hidden <input>'s so you can use everything as post instead. In fact, you might want to look into using $_REQUEST which would store stuff passed onto your script both by post AND by get (as well as from cookies)...

Sorry if this doesn't help, I don't really understand what it is your are trying to do! :? Maybe if you could just briefly explain what it is you need to do here, with regards to what is being sent as a query string, and why?

paul
08-27-2003, 03:56 PM
Well, I'm using Dreamweaver MX and this is the code that is produced. I'm very new to web development and all the components. (php, dreamweaver and mySql). All I want to do is submit form data into my database--It wasn't supposed to be this difficult! :( Thanks for taking a look.--Paul