Page 1 of 1

Form Values not passing on

Posted: Thu Mar 13, 2003 12:02 pm
by Aathos
Ok, I just moved to a new hosting service and everything was working fine before the move. My problem is this ...after a user fills out a form and hits submit, it is supposed to send them to another page, which updates my database and then redirects them back home. Well, my form values are NOT getting passed on to the update PHP page. I've looked everything over on the server and my code (which there is nothing wrong with ..it was working before!) ..but support says nothing is wrong with the server either .../sigh ..this is driving me crazy. Anyways, I don't have a clue what to do now. I've looked over everything that I know of, so if anyone has any other suggestions please let me know.

it's running on windows 2000 server and version 4.3.1

any help would be greatly appreciated.
thanks

Posted: Thu Mar 13, 2003 12:34 pm
by daven
Does your code use $_POST/$_GET to access the variables, or does it merely use $varName? If the latter, you must change to the superglobals.

Toss some of your code up so we can look at it.

Also, make sure that the PHP settings on your new host are the same as on your old host.

Posted: Thu Mar 13, 2003 12:49 pm
by Aathos
Here's the form

Code: Select all

<?
	include "myconn.php";
	
	$query = "SELECT * FROM admin";
	$result = mysql_query($query);
	$result = mysql_fetch_array($result);
	
	$limit = $result&#1111;'default_limit'];
?>
<title> Change Default Job Limit </title>
<form name = 'limit' action = 'a_adminLimit.php' method = 'post'>
<center>
<table border = '0' width = 100%>
<tr>
<td align = 'center' width = 50%> Enter new Default Job Limit </td>
<td align = 'center'> <input type = 'text' name = 'newLimit' value = '<?echo $limit ?>' size = '5'> </td>
</tr>

<tr>
<td align = 'center'> <input type = 'submit' name = 'submit' value = 'Change'> </td>
<td align = 'center'> <input type = 'reset' name = 'reset' value = 'Reset'> </td>
</tr>

<tr>
<td align = 'center' colspan = '2'> <a href = 'javascript: self.close();'> Close </a> </td>
</tr>
</table>
</form>

<script language = 'javascript'>
<!--

document.limit.newLimit.focus();

-->
</script>

Here's the update page

Code: Select all

<?
If (!$submit) &#123;
?>
    <center>
    Restricted
    <br>
    <a href = 'javascript: self.close();'> Close </a>
    </center>
    
<? 
&#125; else &#123;
	include "myconn.php";
	$query = "UPDATE admin set
			default_limit = $newLimit"
			or die("Cannot query");
	$result = mysql_query($query)
	or die("Cannot result");
?>

<center>
Default job limit has now been updated to <?echo $newLimit ?>
<br>
<a href = 'javascript: self.close();'> Close </a>
</center>

<? &#125; ?>
I also tried using $newLimit_POST and it still didn't work. We're using something new to me for hosting ..it's a reseller package that allows us to setup hosting packages and the such. I've looked through everything a few times and it seems that everything is set fine, though I really didn't see any PHP options ..i'm assuming everything is setup like the old host ..though i'm not for certain and I really don't know how to go about checking it out.

Thanks

Posted: Thu Mar 13, 2003 1:04 pm
by daven
Revised code is below. What you need to do is use $_POST['var'] instead of just $var. ie--to access the posted value of $newLimit, you need to use $_POST['newLimit']. PHP 4x does not like accessing form variables by name alone.

If you use a GET form, you access the variables via $_GET['var']

<?
if (!$submit) { // 'if' should be lowercase
?>
<center>
Restricted
<br>
<a href = 'javascript: self.close();'> Close </a>
</center>

<?
} else {
include "myconn.php";
$query = "UPDATE admin set
default_limit = $$_POST['newLimit']"
or die("Cannot query");
$result = mysql_query($query)
or die("Cannot result");
?>

<center>
Default job limit has now been updated to <?echo $_POST['newLimit'] ?>
<br>
<a href = 'javascript: self.close();'> Close </a>
</center>

<? } ?>

Posted: Thu Mar 13, 2003 1:10 pm
by Aathos
Awesome!!! Hell yeah, thank you soooooo much! I didn't know that about php4 ..i liked the way php3 handled the variables. $varName is just too easy not to like. Anyways, thanks again =)

Posted: Fri Mar 14, 2003 2:01 am
by twigletmac
This may be of interest:
viewtopic.php?t=511

Mac