wright67uk Posted November 27, 2012 Share Posted November 27, 2012 I'm new to session variables, and I'm using the code below as an attempt to pass info from 1 page to another as part of a 2 part form. I'm echoing the variables in the second page but get no values returned. Below is my initial page, any kind comments as to where I'm going wrong? <?php session_start(); session_register('name'); session_register('email'); session_register('phone'); session_register('postcode'); session_register('type'); session_register('start'); session_register('description'); $_SESSION['name'] = $_POST['name']; $_SESSION['email'] = $_POST['email']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['postcode'] = $_POST['postcode']; $_SESSION['type'] = $_POST['type']; $_SESSION['start'] = $_POST['start']; $_SESSION['description'] = $_POST['description']; ?> <!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" /> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="clientform"> <p>Please enter your details below, and 3 of your local tree surgeons will get in touch! or <a href="login.html">login</a><br /><br/></p> <form action="client_start_2.php" method="post"> <p class="left"><label for="name" class="required">Your Name</label><br> <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p> <p class="right"><label for="email" class="required">Your Email Address</label><br> <input class="field required" id="email" name="email" placeholder="Your Email Address" required tabindex="1" type="email"></p> <div style="clear:both" /> <p class="left"><label for="phone">Your Phone Number</label><br> <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="3" type="text"></p> <p class="right"><label for="postcode">Your Full Postcode</label><br> <input class="field" id="postcode" name="postcode" placeholder="Your Full Postcode" tabindex="4" type="text"></p> <div style="clear:both" /> <p class="left"><label for="type" class="required">Type of works</label><br> <select class="dropdown required" id="type" name="type" required="required" tabindex="9"> <option value=""> Please Select </option> <option value="1">Tree Surgery</option> <option value="2">Stump Grinding</option> <option value="3">Tree Surgery and Stump Grinding</option> </select></p> <p class="right"><label for="phone">Ideal Start Date</label><br> <input class="field" id="start" name="start" placeholder="Your Ideal Start Date" tabindex="5" type="text"></p> <div style="clear:both"> <p class="left"><label for="question" class="required">Brief Description of Works</label><br> <textarea class="textarea required" id="description" name="description" placeholder="Job Description" required tabindex="10"></textarea></p> <p class="button"><button tabindex="6" type="submit">Submit</button></p> <div style="clear:both" /> </form> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/271232-no-returned-values-using-session-veriables/ Share on other sites More sharing options...
Muddy_Funster Posted November 27, 2012 Share Posted November 27, 2012 drop all the lines that have session_register on them, you also don't have the values in the post array untill after the form is submitted, so the $_SESSION['...'] = $_POST['...'] lines should actualy be throwing up notices/warnings to the effect that $_POST[...] is not initialised or is an invalid index. the $_POST array will take the values to the next page, it's there that you would assign them to the $_SESSION array if you want to take them to a third page. Link to comment https://forums.phpfreaks.com/topic/271232-no-returned-values-using-session-veriables/#findComment-1395440 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.