OriginalBoy Posted October 26, 2008 Share Posted October 26, 2008 I have a form which submits and if there is an error it sends to this page... if (isset($_SESSION['error']) && $_SESSION['error'] == true){ header("location:./?page=register&error=true"); } When it sends it just takes it to the homepage. if ($_GET['error'] == true && $_SESSION['error'] == true){ $fname = $_SESSION['fname']; $lname = $_SESSION['lname']; $email = $_SESSION['email']; $secq = $_SESSION['secq']; $seca = $_SESSION['seca']; $bname = $_SESSION['bname']; $budget = $_SESSION['budget']; $deadline = $_SESSION['deadline']; $other = $_SESSION['other']; if (isset($_SESSION['error_firstname'])){ $fname_color = "#CC0000"; } else{ $fname_color = "#ffffff"; } if (isset($_SESSION['error_lastname'])){ $lname_color = "#CC0000"; } else{ $lname_color = "#ffffff"; } if (isset($_SESSION['error_email'])){ $email_color = "#CC0000"; } else{ $email_color = "#ffffff"; } if (isset($_SESSION['error_secretq'])){ $sq_color = "#CC0000"; } else{ $sq_color = "#ffffff"; } if (isset($_SESSION['error_secreta'])){ $sa_color = "#CC0000"; } else{ $sa_color = "#ffffff"; } if (isset($_SESSION['error_work'])){ $work_color = "#CC0000"; } else{ $work_color = "#ffffff"; } if (isset($_SESSION['other'])){ $other_color = "#CC0000"; } else{ $other_color = "#ffffff"; } if (isset($_SESSION['error_username']) || isset($_SESSION['error_password']) || isset($_SESSION['error_tos']) || isset($_SESSION['error_email'])){ print "<p>Errors found. Please review the form.</p> <p>Errors are in red</p>"; } echo<<<END <form name="client" method="post" action="p_developer.php"> <table width="400" border="0" align="center"> <tr> <td>* First Name:</td> <td><input type="text" name="fname" id="fname" size="8" value="$fname" style="background:$fname_color"/></td> </tr> <tr> <td>* Last Name:</td> <td><input type="text" name="lname" id="lname" size="8" value="$lname" style="background:$lname_color"/></td> </tr> <tr> <td>* Email:</td> <td><input type="text" name="email" id="email" size="8" value="$email" style="background:$email_color"/></td> </tr> <tr> <td>* Confirm Email:</td> <td><input type="text" name="confirmemail" id="confirmemail" size="8" value="$email" style="background:$email_color"/></td> </tr> <tr> <td>* Security Question:</td> <td><input type="text" name="security" id="security" size="8" value="$secq" style="background:$sq_color"/></td> </tr> <tr> <td>* Security Answer:</td> <td><input type="text" name="securityanswer" id="answer" size="8" value="$seca" style="background:$sa_color"/></td> </tr> <tr> <td>Business Name:</td> <td><input type="text" name="bname" size="8"/></td> </tr> <tr> <td>Budget:</td> <td><input type="text" name="budget" id="budget" size="8" value="$budget" /></td> </tr> <tr> <td>Deadline:</td> <td><input type="text" name="deadline" rows="5" id="deadline" size="8" value="$deadline" /></td> </tr> <tr> <td>* All other details:</td> <td><textarea name="other" rows="5" id="other" value="$other" size="8" style="background:$other_color"></textarea></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit" /></td> <td> </td> </tr> </table> END; } Any suggestions? Thanks, Steve Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/ Share on other sites More sharing options...
budimir Posted October 26, 2008 Share Posted October 26, 2008 How do you mean not working? Where do you get value for $_GET['error']? Try to echo $_GET['error'] to see what it holds! Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-674985 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 Here is how it is defined... if (!strstr($email, "@") || !strstr($email, ".") || $email == "" || $email != $email2){ $_SESSION['error_email'] = true; $_SESSION['error'] = true; } if (!(isset($fname)) || $fname == ""){ $_SESSION['error_firstname'] = true; $_SESSION['error'] = true; } if (!(isset($lname)) || $lname == ""){ $_SESSION['error_lastname'] = true; $_SESSION['error'] = true; } if (!(isset($sq)) || $sq == ""){ $_SESSION['error_secretq'] = true; $_SESSION['error'] = true; } if (!(isset($sa)) || $sa == ""){ $_SESSION['error_secreta'] = true; $_SESSION['error'] = true; } if (isset($_SESSION['error']) && $_SESSION['error'] == true){ header("location:./?page=register&error=true"); } Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675026 Share on other sites More sharing options...
kenshintomoe225 Posted October 26, 2008 Share Posted October 26, 2008 Can you post the form as well please? This only shows how $_SESSION is being set, not $_GET Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675032 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 http://www.developersmatch.com/developersmatch/client/index%20copy.php you can see what happens there... here is the code... <?php if ($_GET['error'] == true && $_SESSION['error'] == true){ $fname = $_SESSION['fname']; $lname = $_SESSION['lname']; $email = $_SESSION['email']; $secq = $_SESSION['secq']; $seca = $_SESSION['seca']; $bname = $_SESSION['bname']; $budget = $_SESSION['budget']; $deadline = $_SESSION['deadline']; $other = $_SESSION['other']; if (isset($_SESSION['error_firstname'])){ $fname_color = "#CC0000"; } else{ $fname_color = "#ffffff"; } if (isset($_SESSION['error_lastname'])){ $lname_color = "#CC0000"; } else{ $lname_color = "#ffffff"; } if (isset($_SESSION['error_email'])){ $email_color = "#CC0000"; } else{ $email_color = "#ffffff"; } if (isset($_SESSION['error_secretq'])){ $sq_color = "#CC0000"; } else{ $sq_color = "#ffffff"; } if (isset($_SESSION['error_secreta'])){ $sa_color = "#CC0000"; } else{ $sa_color = "#ffffff"; } if (isset($_SESSION['error_work'])){ $work_color = "#CC0000"; } else{ $work_color = "#ffffff"; } if (isset($_SESSION['other'])){ $other_color = "#CC0000"; } else{ $other_color = "#ffffff"; } if (isset($_SESSION['error_username']) || isset($_SESSION['error_password']) || isset($_SESSION['error_tos']) || isset($_SESSION['error_email'])){ print "<p>Errors found. Please review the form.</p> <p>Errors are in red</p>"; } echo<<<END <form name="client" method="post" action="p_developer.php"> <table width="400" border="0" align="center"> <tr> <td>* First Name:</td> <td><input type="text" name="fname" id="fname" size="8" value="$fname" style="background:$fname_color"/></td> </tr> <tr> <td>* Last Name:</td> <td><input type="text" name="lname" id="lname" size="8" value="$lname" style="background:$lname_color"/></td> </tr> <tr> <td>* Email:</td> <td><input type="text" name="email" id="email" size="8" value="$email" style="background:$email_color"/></td> </tr> <tr> <td>* Confirm Email:</td> <td><input type="text" name="confirmemail" id="confirmemail" size="8" value="$email" style="background:$email_color"/></td> </tr> <tr> <td>* Security Question:</td> <td><input type="text" name="security" id="security" size="8" value="$secq" style="background:$sq_color"/></td> </tr> <tr> <td>* Security Answer:</td> <td><input type="text" name="securityanswer" id="answer" size="8" value="$seca" style="background:$sa_color"/></td> </tr> <tr> <td>Business Name:</td> <td><input type="text" name="bname" size="8"/></td> </tr> <tr> <td>Budget:</td> <td><input type="text" name="budget" id="budget" size="8" value="$budget" /></td> </tr> <tr> <td>Deadline:</td> <td><input type="text" name="deadline" rows="5" id="deadline" size="8" value="$deadline" /></td> </tr> <tr> <td>* All other details:</td> <td><textarea name="other" rows="5" id="other" value="$other" size="8" style="background:$other_color"></textarea></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit" /></td> <td> </td> </tr> </table> END; } elseif(isset($_GET['register']) && $_GET['register'] == success){ print "<p>Account created Successfully!</p>\n<p>Please check your inbox to verify your email address<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"; } else{ ?> <form name="client" method="post" action="p_developer.php"> <table width="400" border="0" align="center"> <tr> <td>* First Name:</td> <td><input type="text" name="fname" id="fname" size="8" /></td> </tr> <tr> <td>* Last Name:</td> <td><input type="text" name="lname" id="lname" size="8" /></td> </tr> <tr> <td>* Email:</td> <td><input type="text" name="email" id="email" size="8" /></td> </tr> <tr> <td>* Confirm Email:</td> <td><input type="text" name="confirmemail" id="confirmemail" size="8"/></td> </tr> <tr> <td>* Security Question:</td> <td><input type="text" name="security" id="security" size="8" /></td> </tr> <tr> <td>* Security Answer:</td> <td><input type="text" name="securityanswer" id="answer" size="8"/></td> </tr> <tr> <td>Business Name:</td> <td><input type="text" name="bname" size="8"/></td> </tr> <tr> <td>Budget:</td> <td><input type="text" name="budget" id="budget" size="8" /></td> </tr> <tr> <td>Deadline:</td> <td><input type="text" name="deadline" rows="5" id="deadline" size="8" /></td> </tr> <tr> <td>All other details:</td> <td><textarea name="other" rows="5" id="other" size="8"></textarea></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit" /></td> <td> </td> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675038 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 Please post the from process code Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675072 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 Here is the whole of p_developer.php <?php include("../config.inc.php"); session_start(); session_destroy(); include("../functions.inc.php"); session_start(); $fname = clean_data($_POST['fname']); $lname = clean_data($_POST['lname']); $email = clean_data($_POST['email']); $email2 = clean_data($_POST['confirmemail']); $sq = clean_data($_POST['security']); $sa = clean_data($_POST['securityanswer']); $bname = clean_data($_POST['bname']); $budget = clean_data($_POST['budget']); $deadline = clean_data($_POST['deadline']); $otherinfo = clean_data($_POST['other']); $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['email'] = $email; $_SESSION['secq'] = $sq; $_SESSION['seca'] = $sa; $_SESSION['bname'] = $bname; $_SESSION['budget'] = $budget; $_SESSION['deadline'] = $deadline; $_SESSION['other'] = $otherinfo; $skill_count = 0; if (!strstr($email, "@") || !strstr($email, ".") || $email == "" || $email != $email2){ $_SESSION['error_email'] = true; $_SESSION['error'] = true; } if (!(isset($fname)) || $fname == ""){ $_SESSION['error_firstname'] = true; $_SESSION['error'] = true; } if (!(isset($lname)) || $lname == ""){ $_SESSION['error_lastname'] = true; $_SESSION['error'] = true; } if (!(isset($sq)) || $sq == ""){ $_SESSION['error_secretq'] = true; $_SESSION['error'] = true; } if (!(isset($sa)) || $sa == ""){ $_SESSION['error_secreta'] = true; $_SESSION['error'] = true; } if (isset($_SESSION['error']) && $_SESSION['error'] == true){ header("location:./?page=register&error=true"); } else{ $sql = "INSERT INTO `clients` (first_name, last_name, email, security_question, security_answer, business_name, budget, deadline, other_details) VALUES('$fname', '$lname', '$email', '$sq', '$sa', '$bname', '$budget', '$deadline', '$otherinfo');"; mysql_query($sql); $to = $_POST['email']; $from = "'Developers Match'<contact@developersmatch.com>"; $subject = "Welcome"; $message = "Thank you for signing up you will be contacted shortly with any developers we find. For any support please read our FAQ online and you can email us on\n\r \n\r Email - contact@developersmatch.com\n\r \n\r Best Regards, \n\r DevelopersMatch.com"; $headers = "From: $from\r\n"; mail($to, $subject, $message, $headers) or die("ERROR!"); $to = 'contact@developersmatch.com'; $from = "'Developers Match'<contact@developersmatch.com>"; $subject = "New Client"; $message = "$fname $lname has signed up as a client to our service. Please make him feel comftable in our service with friendly and personal contact. All details can be found on the database. His/Her email is $email"; $headers = "From: $from\r\n"; mail($to, $subject, $message, $headers) or die("ERROR!"); header("location:./?page=register®ister=success"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675074 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 shundt this be header("location:./?page=register&error=true"); This header("location:index20%copy.php/?page=register&error=true"); Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675077 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 this always used to work without this and with this it does not work comes up showing no page. I don't think the issue is caused there Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675128 Share on other sites More sharing options...
Andy-H Posted October 26, 2008 Share Posted October 26, 2008 In http://www.developersmatch.com/developersmatch/client/index%20copy.php you are using sessions without using session_start() to initialise the session. Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675141 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 I added that but it still does the same thing and goes back to the homepage if u fill it out with some errors and submit you will see. Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675161 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 Then it must be being directed there, check your code for any headers etc. that might be doing this, check all the pages that the form can possibly go to. Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675164 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 no i don't mean like that it goes to the right page just shows the homepage content Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675179 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 try removing && $_SESSION['error'] == true Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675181 Share on other sites More sharing options...
OriginalBoy Posted October 26, 2008 Author Share Posted October 26, 2008 still same problem Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675189 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 OK, then sorry but your code is to untidy (makes it hard to read) and there are to many if statements in your code. My advice would be to have the form self post and then present any error messages on that page. Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675206 Share on other sites More sharing options...
jonsjava Posted October 27, 2008 Share Posted October 27, 2008 I don't have the time to debug the whole thing, but this should fix it <?php include("../config.inc.php"); session_start(); session_unset(); include("../functions.inc.php"); $fname = clean_data($_POST['fname']); $lname = clean_data($_POST['lname']); $email = clean_data($_POST['email']); $email2 = clean_data($_POST['confirmemail']); $sq = clean_data($_POST['security']); $sa = clean_data($_POST['securityanswer']); $bname = clean_data($_POST['bname']); $budget = clean_data($_POST['budget']); $deadline = clean_data($_POST['deadline']); $otherinfo = clean_data($_POST['other']); $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['email'] = $email; $_SESSION['secq'] = $sq; $_SESSION['seca'] = $sa; $_SESSION['bname'] = $bname; $_SESSION['budget'] = $budget; $_SESSION['deadline'] = $deadline; $_SESSION['other'] = $otherinfo; $skill_count = 0; if (!strstr($email, "@") || !strstr($email, ".") || $email == "" || $email != $email2){ $_SESSION['error_email'] = true; $_SESSION['error'] = true; } if (!(isset($fname)) || $fname == ""){ $_SESSION['error_firstname'] = true; $_SESSION['error'] = true; } if (!(isset($lname)) || $lname == ""){ $_SESSION['error_lastname'] = true; $_SESSION['error'] = true; } if (!(isset($sq)) || $sq == ""){ $_SESSION['error_secretq'] = true; $_SESSION['error'] = true; } if (!(isset($sa)) || $sa == ""){ $_SESSION['error_secreta'] = true; $_SESSION['error'] = true; } if (isset($_SESSION['error']) && $_SESSION['error'] == true){ header("location:./?page=register&error=true"); } else{ $sql = "INSERT INTO `clients` (first_name, last_name, email, security_question, security_answer, business_name, budget, deadline, other_details) VALUES('$fname', '$lname', '$email', '$sq', '$sa', '$bname', '$budget', '$deadline', '$otherinfo');"; mysql_query($sql); $to = $_POST['email']; $from = "'Developers Match'<contact@developersmatch.com>"; $subject = "Welcome"; $message = "Thank you for signing up you will be contacted shortly with any developers we find. For any support please read our FAQ online and you can email us on\n\r \n\r Email - contact@developersmatch.com\n\r \n\r Best Regards, \n\r DevelopersMatch.com"; $headers = "From: $from\r\n"; mail($to, $subject, $message, $headers) or die("ERROR!"); $to = 'contact@developersmatch.com'; $from = "'Developers Match'<contact@developersmatch.com>"; $subject = "New Client"; $message = "$fname $lname has signed up as a client to our service.\r\n Please make him feel comftable in our service with friendly and personal\r\n contact. All details can be found on the database.\r\n His/Her email is $email"; $headers = "From: $from\r\n"; mail($to, $subject, $message, $headers) or die("ERROR!"); header("location:./?page=register®ister=success"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675360 Share on other sites More sharing options...
OriginalBoy Posted October 27, 2008 Author Share Posted October 27, 2008 I changed it to that code and had no luck still. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675524 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2008 Share Posted October 27, 2008 overly complex, phsycometric complexity of 1000 000 000 000 (terra) Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675526 Share on other sites More sharing options...
DeanWhitehouse Posted October 27, 2008 Share Posted October 27, 2008 I'm afraid we will not sit here and keep writing changes to your code for you, take my advice, rewrite it and keep it simple. Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675527 Share on other sites More sharing options...
OriginalBoy Posted October 27, 2008 Author Share Posted October 27, 2008 I need it to use sessions though so it can remember the data if something goes wrong. Does anyone have a tutorial to look at? Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675532 Share on other sites More sharing options...
DeanWhitehouse Posted October 27, 2008 Share Posted October 27, 2008 Read what i wrote, if it post's to it's self then it will store the data in the $_POST Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675536 Share on other sites More sharing options...
OriginalBoy Posted October 27, 2008 Author Share Posted October 27, 2008 I don't get this can you explain a bit more? Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675548 Share on other sites More sharing options...
DeanWhitehouse Posted October 27, 2008 Share Posted October 27, 2008 Post the form to the same page it's on, then do all the form processing there and the error checking, then you can show errors without using $_GET at all. Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675563 Share on other sites More sharing options...
OriginalBoy Posted October 27, 2008 Author Share Posted October 27, 2008 Ugh where do i put it all...do u have an example code? Quote Link to comment https://forums.phpfreaks.com/topic/130163-get-not-working/#findComment-675573 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.