HDFilmMaker2112 Posted May 29, 2011 Share Posted May 29, 2011 The below is flagging errors #3 and #9. Error #3 is being thrown even though the emails match. <?php session_start(); $_SESSION['submitted']="yes"; $error=$_GET['error']; $date_rma="5/10/2011"; $content=' <div class="content_text"> <div class="content_header">Request RMA Number</div> <p>Enter the information you used on PayPal, that you completed your order with. The information must match, or a RMA Number will not be issued.</p> <form action="./rma_process.php" method="post"> <p><label>Name:</label> <input type="text" name="name" size="30" value="'.(isset($_SESSION['name']) ? $_SESSION['name'] : '').'" />'; if($error[0]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='</p> <p><label>E-Mail Address:</label> <input type="email" name="email" size="35" value="'.(isset($_SESSION['email']) ? $_SESSION['email'] : '').'" />'; if($error[1]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='</p> <p><label>Confirm E-Mail Address:</label> <input type="email" name="confirm_email" size="35" value="'.(isset($_SESSION['confirm_email']) ? $_SESSION['confirm_email'] : '').'" />'; if($error[2]==1){ $content.=' <span class="red bold">This field is required.</span>'; } if($error[3]==1){ $content.=' <span class="red bold">E-Mail addresses do not match.</span>'; } $content.='</p> <p><label>Phone Number:</label> <input type="text" name="phone" size="15" value="'.(isset($_SESSION['phone']) ? $_SESSION['phone'] : '').'" /> Ext. <input type="text" name="ext" size="4" value="'.(isset($_SESSION['ext']) ? $_SESSION['ext'] : '').'" />'; if($error[4]==1){ $content.=' <span class="red bold">A properly formatted phone number is required.</span>'; } $content.='</p> <p><label>Date of Purchase (MM/DD/YYYY):</label><input type="text" name="month" size="2" maxlength="2" value="'.(isset($_SESSION['month']) ? $_SESSION['month'] : '').'" /> <input type="text" name="day" size="2" maxlength="2" value="'.(isset($_SESSION['day']) ? $_SESSION['day'] : '').'" /> <input type="text" name="year" size="5" maxlength="4" value="'.(isset($_SESSION['year']) ? $_SESSION['year'] : '').'" />'; if($error[5]==1 || $error[6]==1 || $error[7]==1){ $content.=' <span class="red bold">A properly formatted date is required.</span>'; } $content.='</p><p><label>List the Products you wish to return. Sperate with a comma. <br />Use either the whole product name, or the GHP# Product Code:</label>'; if($error[8]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='<textarea name="products_returning" rows="10" cols="60"> '.(isset($_SESSION['products_returning']) ? $_SESSION['products_returning'] : '').''; $content.=' </textarea> <input type="hidden" name="submitted" value="yes" /> </p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> </div> '; ?> <?php session_start(); $name = $_POST['name']; $_SESSION['name']=$name; if($name==""){ $error0=1; } else{ $error0=0; } $email = $_POST['email']; $_SESSION['email']=$email; if($email==""){ $error1=1; } else{ $error1=0; } $confirm_email = $_POST['confirm_email']; $_SESSION['confirm_email']=$confirm_email; if($confirm_email==""){ $error2=1; } else{ $error2=0; } if($email!=$confirm_email){ $error3=1; } else{ $error3=0; } $phone = $_POST['phone']; $_SESSION['phone']=$phone; if($phone==""){ $error4=1; } else{ $error4=0; } $ext = $_POST['ext']; $_SESSION['ext']=$ext; $phone = $phone.' Ext.'.$ext; $month = $_POST['month']; $_SESSION['month']=$month; if($month=="" || !is_numeric($month)){ $error5=1; } else{ $error5=0; } $day = $_POST['day']; $_SESSION['day']=$day; if($day=="" || !is_numeric($day)){ $error6=1; } else{ $error6=0; } $year = $_POST['year']; $_SESSION['year']=$year; if($year=="" || !is_numeric($year)){ $error7=1; } else{ $error7=0; } $date="".$month."/".$day."/".$year.""; $products_returning = $_POST['products_returning']; $_SESSION['products_returning']=$products_returning; if($products_returning==""){ $error8=1; } else{ $error8=0; } if($_SESSION['submitted']=="yes"){ $error9=0; } else{ $error9=1; } $error="".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."".$error7."".$error8."".$error9.""; if($error!=="0000000000"){ header("Location: ./index.php?returns=rma&error=".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."".$error7."".$error8."".$error9.""); } else{ header("Location: ./index.php?returns=submitted"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/ Share on other sites More sharing options...
HDFilmMaker2112 Posted May 29, 2011 Author Share Posted May 29, 2011 Error 3 solved... need #9 fixed now. Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221791 Share on other sites More sharing options...
seanlim Posted May 29, 2011 Share Posted May 29, 2011 You did not declare $_SESSION['submitted']. I doubt you want to store a $_SESSION['submitted'], so I would suggest trying if($_POST['submitted']=="yes"){ Instead of if($_SESSION['submitted']=="yes"){ Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221800 Share on other sites More sharing options...
HDFilmMaker2112 Posted May 29, 2011 Author Share Posted May 29, 2011 You did not declare $_SESSION['submitted']. I doubt you want to store a $_SESSION['submitted'], so I would suggest trying if($_POST['submitted']=="yes"){ Instead of if($_SESSION['submitted']=="yes"){ I did in the first page: $_SESSION['submitted']="yes"; Just below session_start(); I'm trying to use hidden inputs as little as possible. I removed the <input type="hidden"> tag. Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221801 Share on other sites More sharing options...
HDFilmMaker2112 Posted May 29, 2011 Author Share Posted May 29, 2011 Well I changed it to $_POST and added back the input hidden field, and it;s still throwing the damn error. Really starting piss me off as I'm seeing absolutely no errors in either way of doing it. Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221813 Share on other sites More sharing options...
seanlim Posted May 29, 2011 Share Posted May 29, 2011 Tested your code and it works fine... only had to add in a few lines of code to properly parse the $_GET['error'] into the $error array. I suppose you have omitted that from the code you posted? Can you try var_dump($_SESSION), or more specifically $_SESSION['submitted'] in the error checking portion? Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221814 Share on other sites More sharing options...
HDFilmMaker2112 Posted May 29, 2011 Author Share Posted May 29, 2011 Tested your code and it works fine... only had to add in a few lines of code to properly parse the $_GET['error'] into the $error array. I suppose you have omitted that from the code you posted? Nope, the $error variable is working as I have it in the code posted. var_dump returns: array(9) { ["name"]=> string(4) "test" ["email"]=> string(16) "test@exmaple.com" ["confirm_email"]=> string(16) "test@example.com" ["phone"]=> string(12) "123123123123" ["ext"]=> string(0) "" ["month"]=> string(2) "12" ["day"]=> string(2) "12" ["year"]=> string(4) "1212" ["products_returning"]=> string(46) "asdfasdfsadfswdfsadfasfasfsafdasdfasdfasdfasdf" } Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221815 Share on other sites More sharing options...
HDFilmMaker2112 Posted May 29, 2011 Author Share Posted May 29, 2011 Found the issue... I killed the session on index.php at the bottom of the page... rma.php (the one with the form) is included into index.php. Index.php is basically the layout of the site, while rma.php is the content for ?returns=rma. So $_SESSION['submitted'] was being killed before it was even sent to the next page. Quote Link to comment https://forums.phpfreaks.com/topic/237755-form-error-checking-issue/#findComment-1221817 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.