Page 1 of 1

Passing form values

Posted: Fri Nov 15, 2002 12:19 pm
by ylime243
I'm new to all this PHP stuff....

I'm having trouble passing form values when I run my scripts on localhost. When I run my scripts on localhost I get this error

Notice: Undefined variable: text_fname in c:\inetpub\wwwroot\php_fun\form1_action.php on line 23

Even though I've tested to make sure the values are being passed using the GET method.

Also when I upload the pages to the server the scripts work fine.

Any help would be great.

Thanks!

Emily

Posted: Fri Nov 15, 2002 12:41 pm
by BDKR
Notice: Undefined variable: text_fname in c:\inetpub\wwwroot\php_fun\form1_action.php on line 23
Notice (pun intended) that the message says notice. 8O Your script will probably work just fine once inspite of it.

What it's saying is that the script is trying to do something with a var that doesn't exist. I can understand that it probably will exist later in the script, but at line 23, it doesn't. The easy thing to do is somewhere like line 1 say error_reporting(0) for when the script has been uploaded to the production server.

Let's see the code. It's probably something simple to sort out.

Cheers,
BDKR

Posted: Fri Nov 15, 2002 2:33 pm
by oldtimer
I agree. It would be helpful to see your code. At least several lines before and after it.

Here's the code

Posted: Fri Nov 15, 2002 2:37 pm
by ylime243
Like I said before it works fine on the server and the code is quite simple. It just won't work using IIS on my local machine.

thanks for you help
Here's the code:

form1.php

<html>
<head>
<title>FORM 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="includes/styles.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form method=GET action="form1_action.php">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">First Name</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<input type="text" name="text_fname">
</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">Last Name</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<input type="text" name="text_lname">
</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">Address</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<input type="text" name="text_address">
</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">City </td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<input type="text" name="text_city">
</td>
</tr>
<tr>
<td width="10" height="21">&nbsp;</td>
<td width="100" align="left" valign="top" class="body" height="21">State</td>
<td width="10" height="21">&nbsp;</td>
<td width="180" align="left" valign="top" class="body" height="21">
<select name="select_state">
<option value="PA">PA</option>
<option value="CO">CO</option>
</select>
</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">Zip</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<input type="text" name="text_zip">
</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

form1_action.php

<html>
<head>
<title>FORM 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="includes/styles.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">First Name</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">
<?php

print "Your First Name is $text_fname";


?></td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">Last Name</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">Address</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp; </td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">City </td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp; </td>
</tr>
<tr>
<td width="10" height="21">&nbsp;</td>
<td width="100" align="left" valign="top" class="body" height="21">State</td>
<td width="10" height="21">&nbsp;</td>
<td width="180" align="left" valign="top" class="body" height="21">&nbsp; </td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">Zip</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp; </td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp; </td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="100" align="left" valign="top" class="body">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="180" align="left" valign="top" class="body">&nbsp;</td>
</tr>
</table>
</body>
</html>

Posted: Fri Nov 15, 2002 2:47 pm
by oldtimer
You are right in that it works on unix. I did notice you useing GET instead of POST. Any reason for that. I personally dont like all the fields getting put in the URL.

Sorry I am not any help for you. I run 2k but dont have it setup for any local web testing.

Reason for using Get

Posted: Fri Nov 15, 2002 2:50 pm
by ylime243
I only put get in there to test to make sure the values were being passed....I would normally use POST....

Let me know if you think of anything else....

Thanks for your time.

Posted: Fri Nov 15, 2002 3:00 pm
by oldtimer
That makees more sence then what I do. I usualy echo it out while setting up stuff to enter a DB. then remove it once i see it is working.

I found the answer

Posted: Fri Nov 15, 2002 4:51 pm
by ylime243
You have to go into your php.ini file and change the register_global variable to on.


Phew!! Hope this helps someone out.

Posted: Mon Nov 18, 2002 2:55 am
by twigletmac
One reason for not putting register_globals on (and this is covered here: viewtopic.php?t=511) and for learning to cope with it off, is that it is now been deprecated so it is not going to be around for ever at some point you are going to have to rewrite all your scripts if they all rely on reg_globals on.

Mac