Jump to content

tarafenton

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tarafenton's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I got it It was that I had $_SESSION['fname'] = $_REQUEST['fname']; $_SESSION['lname'] = $_REQUEST['lname']; $_SESSION['sname'] = $_REQUEST['sname']; $_SESSION['grade'] = $_REQUEST['grade']; $_SESSION['address'] = $_REQUEST['address']; $_SESSION['city'] = $_REQUEST['city']; $_SESSION['state'] = $_REQUEST['state']; $_SESSION['zip'] = $_REQUEST['zip']; $_SESSION['email'] = $_REQUEST['email']; in index.php that was refreshing the values
  2. the text fields are empty when the user fills out the form incompletely, even though i have the sessions set up
  3. Hello, I am trying to use sessions to retain the value of the text fields in a form, if the user does not complete the form, the users is redirected to the form, BUT the form fields are refreshed.  I want what ever the user filled into the form to appear when the user is redirected to the form.  PLEASE help with any suggestions. TIA, Tara Here is my code------------- index2.php <?php   session_start(); $_SESSION['fname'] = $_REQUEST['fname']; $_SESSION['lname'] = $_REQUEST['lname']; $_SESSION['sname'] = $_REQUEST['sname']; $_SESSION['grade'] = $_REQUEST['grade']; $_SESSION['address'] = $_REQUEST['address']; $_SESSION['city'] = $_REQUEST['city']; $_SESSION['state'] = $_REQUEST['state']; $_SESSION['zip'] = $_REQUEST['zip']; $_SESSION['email'] = $_REQUEST['email'];   if (!isset($_SESSION['msg']))     $_SESSION['msg']="* All fields are required fields"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> Halloween Smiles Program</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body topmargin="0px"><table align="center"><tr><td class="form"> <form action="send_form.php" method="post"> <table> <tr><td colspan="2"><img src="title.jpg"></td></tr> <tr><td colspan="2" align="left" class="text"><?php print $_SESSION['msg'] ?></td></tr> <tr><td class="title">First Name: </td><td><input size="30" name="fname" type="text" value="<?php print $_SESSION['fname'] ?>"></td></tr> <tr><td class="title">Last Name: </td><td><input size="30" name="lname" type="text" value="<?php print $_SESSION['lname'] ?>"></td></tr> <tr><td class="title">School Name: </td><td><input size="30" name="sname" type="text" value="<?php print $_SESSION['sname'] ?>"></td></tr> <tr><td class="title">Grade: </td><td><input size="30" name="grade" type="text" value="<?php print $_SESSION['grade'] ?>"></td></tr> <tr><td  colspan="2" align="left" class="text"><br>Please provide the mailing address you would like your wall poster <br> and memory album shipped to:<br></td> </tr> <tr><td class="title">Street Address: </td><td><input size="30" name="address" type="text" value="<?php $_SESSION['address'] ?>"></td></tr> <tr><td class="title">City: </td><td><input size="30" name="city" type="text" value="<?php $_SESSION['city'] ?>"></td></tr> <tr><td class="title">State: </td><td><input size="30" name="state" type="text" value="<?php $_SESSION['state'] ?>"></td></tr> <tr><td class="title">Zip: </td><td><input size="30" name="zip" type="text" value="<?php $_SESSION['zip'] ?>"></td></tr> <tr><td class="title">Email address: </td><td><input size="30" name="email" type="text" value="<?php $_SESSION['email'] ?>"></td></tr> <tr><td  colspan="2" align="left" class="text"><br>Would you like to receive future emails from bsmmedia.com on <br>special offers? <input type="radio" name="future" value="Yes"> Yes <input type="radio" name="future" value="No"> No <br></td> </tr> <tr><td colspan="2" align="center"><input type="submit" value="Submit" class="submit"></td></tr> </table> </form> </td><td valign="top"><img src="pumpkin2.jpg"></td></tr></table> </body> </html> --------------------------------------------------- send_form.php --------------------------------------------------- <?php session_start(); $_SESSION['fname'] = $_REQUEST['fname']; $_SESSION['lname'] = $_REQUEST['lname']; $_SESSION['sname'] = $_REQUEST['sname']; $_SESSION['grade'] = $_REQUEST['grade']; $_SESSION['address'] = $_REQUEST['address']; $_SESSION['city'] = $_REQUEST['city']; $_SESSION['state'] = $_REQUEST['state']; $_SESSION['zip'] = $_REQUEST['zip']; $_SESSION['email'] = $_REQUEST['email']; $dbhost="localhost" ; // Machine on which MySQL Database is running $dbuser="bsm_halloween" ;            // Database User Login $dbpass="H@P1lw3" ;            // Database User Password $database = "bsmmedia" ;      // Database name $tableName = "halloween" ;  // Name of the table   $dblink = mysql_connect($dbhost, $dbuser, $dbpass);   mysql_select_db($database, $dblink); if ((strlen($_REQUEST['fname'])<1) || (strlen($_REQUEST['lname'])<1) || (strlen($_REQUEST['sname'])<1) || (strlen($_REQUEST['grade'])<1) || (strlen($_REQUEST['address'])<1) || (strlen($_REQUEST['city'])<1) || (strlen($_REQUEST['state'])<1) || (strlen($_REQUEST['zip'])<1) || (strlen($_REQUEST['email'])<1))   {   $_SESSION['msg'] = "Please be sure to fill out all required fields.";   $_SESSION['fname'] = $_REQUEST['fname']; print $_SESSION['lname'] = $_REQUEST['lname']; $_SESSION['lname'] = $_REQUEST['lname']; $_SESSION['sname'] = $_REQUEST['sname']; $_SESSION['grade'] = $_REQUEST['grade']; $_SESSION['address'] = $_REQUEST['address']; $_SESSION['city'] = $_REQUEST['city']; $_SESSION['state'] = $_REQUEST['state']; $_SESSION['zip'] = $_REQUEST['zip']; $_SESSION['email'] = $_REQUEST['email']; // Dynamically Assign Key & Value to each Post foreach($_POST as $key=>$value){     $_SESSION[$key]=$value; } ?> header( 'Location: http://www.bsmmedia.com/teachers/index2.php' ) ;   } else { mysql_query("INSERT INTO halloween (first_name, last_name, school_name, grade, address, city, state, zip, email, future_contact) VALUES ('$_REQUEST[fname]', '$_REQUEST[lname]','$_REQUEST[sname]', '$_REQUEST[grade]','$_REQUEST[address]', '$_REQUEST[city]','$_REQUEST[state]', '$_REQUEST[zip]', '$_REQUEST[email]', '$_REQUEST[future]')"); mysql_close($dblink); header( 'Location: http://www.bsmmedia.com/teachers/thanks.html' ) ; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.