bugzy Posted March 29, 2012 Share Posted March 29, 2012 Ok I have this code.. <?php header("Expires: Thu, 17 May 2001 10:17:17 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 session_start(); if (!isset($_SESSION['SESSION'])) require ( "../db_connection.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Registration Form</title> </head> <body><center><br /><br /> <form name="registration" method="post" action="/php/user_registration/registered.php"> <table> <tr> <td>First Name:</td> <td><input type="text" name="fname" value="<?php $_SESSION['fname'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="lname" value="<?php $_SESSION['lname'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>E-Mail Address:</td> <td><input type="text" name="email" value="<?php $_SESSION['email'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Phone:</td> <td><input type="text" name="phone" value="<?php $_SESSION['phone'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" value="<?php $_SESSION['city'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Status:</td> <td> <select name="status" id="status"> <option>Pls. Select One <option value="single">Single <option value="relationship">In a Relationship <option value="complicated">It's Complicated </select> </td> </tr> <tr> <td>Province:</td> <td><input type="text" name="province" value="<?php $_SESSION['province'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" size="30" maxlength="50" /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type="password" name="password2" size="30" maxlength="50" /></td> </tr> <tr> <td> <input type="reset" name="Submit2" value="Reset"></td> <td> <input type="button" name="Submit" value="Submit" onclick="SubmitForm(); return false;" ></td> </tr> </table> </form> </center> </body> </html> I'm not actually doing anything yet up there though I'm having an error on row "province". The error is Undefined index: province in C:\wamp\www\php\user_registration\registration_form.php on line 75 I have tried almost everything and of all the rows I have there, that's the only one I'm having error at. I'm curious why I'm getting that error. Anyone? Quote Link to comment Share on other sites More sharing options...
batwimp Posted March 29, 2012 Share Posted March 29, 2012 It's probably giving you the error because it hasn't been initialized. And of note, those variables aren't actually doing anything. If you want them to print out the actual values in those variables, you need to put echo before them. Quote Link to comment Share on other sites More sharing options...
bugzy Posted March 29, 2012 Author Share Posted March 29, 2012 It's probably giving you the error because it hasn't been initialized. I have no idea why it wouldn't ding you on the previous session variables. And of note, those variables aren't actually doing anything. If you want them to print out the actual values in those variables, you need to put echo before them. Hey like what I said.. those code aren't doing anything yet.. It just so happened that when I try to look at it on the page I see that error and I'm just curious why of all the row I have there that's the only row that is giving me that error.. Quote Link to comment Share on other sites More sharing options...
batwimp Posted March 29, 2012 Share Posted March 29, 2012 Because the variable isn't defined. Even though you aren't printing it out, the server is still trying to access it. If you set the variable (i.e. $_SESSION['province'] = 'none' then it will see that it is initialized and give you an error for the next one up ($_SESSION['city']), and so on until you have actually initialized all of them. Quote Link to comment Share on other sites More sharing options...
bugzy Posted March 29, 2012 Author Share Posted March 29, 2012 Because the variable isn't defined. Even though you aren't printing it out, the server is still trying to access it. If you set the variable (i.e. $_SESSION['province'] = 'none' then it will see that it is initialized and give you an error for the next one up ($_SESSION['city']), and so on until you have actually initialized all of them. Ok I have initialized it and it echoes out the value though the city row doesn't have any error at all. I even tried removing the province row to see if I will get an error on the next one up which is the city or any other row but I got no errors at all. Sorry I'm just new in php and I find it strange. Quote Link to comment Share on other sites More sharing options...
batwimp Posted March 29, 2012 Share Posted March 29, 2012 It could be that you have defined it elsewhere, since it is, after all, a session variable. I plugged in your code to my box and I got an error for all of them, including city. Try setting a default value for all the variables and see if that works. Quote Link to comment Share on other sites More sharing options...
bugzy Posted March 29, 2012 Author Share Posted March 29, 2012 It could be that you have defined it elsewhere, since it is, after all, a session variable. I plugged in your code to my box and I got an error for all of them, including city. Try setting a default value for all the variables and see if that works. Hey I tried to destroy the session and after that all the rows are getting an error now. You are correct maybe I have defined it somewhere else. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.