LindaD Posted May 18, 2009 Share Posted May 18, 2009 How can I add <?php echo $_POST["mail"]; ?> as shown in script below without getting errors?? ?php // get posted data into local variables $mail = Trim($_POST[mail]); if (Trim($mail)=="") {exit("Please enter your E-Mail."); } else { echo "The E-Mail You Entered Is <?php echo $_POST["mail"]; ?> !!"; } ?> Thanks :-X Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/ Share on other sites More sharing options...
Dathremar Posted May 18, 2009 Share Posted May 18, 2009 <?php // get posted data into local variables $mail = trim($_POST[mail]); if (trim($mail)=="") {exit("Please enter your E-Mail."); } else { echo "The E-Mail You Entered Is " . $_POST["mail"]. "!!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836323 Share on other sites More sharing options...
JonnoTheDev Posted May 18, 2009 Share Posted May 18, 2009 There are issues with your code Dathremar. 1. The trim function is being used on a variable that has already been trimmed 2. There is no need to use an else statement after an exit function. The script will terminate if the condition is not met. Thirdly you code should check for a valid email address not just if the field is empty. <?php // get posted data into local variables $mail = trim($_POST['mail']); if(!eregi("^[^@]{1,64}@[^@]{1,255}$", $mail)) { exit("Please enter a valid E-Mail address."); } echo "The E-Mail You Entered Is ".$mail; ?> Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836379 Share on other sites More sharing options...
Dathremar Posted May 18, 2009 Share Posted May 18, 2009 There are issues with your code Dathremar. 1. The trim function is being used on a variable that has already been trimmed 2. There is no need to use an else statement after an exit function. The script will terminate if the condition is not met. Thirdly you code should check for a valid email address not just if the field is empty. <?php // get posted data into local variables $mail = trim($_POST['mail']); if(!eregi("^[^@]{1,64}@[^@]{1,255}$", $mail)) { exit("Please enter a valid E-Mail address."); } echo "The E-Mail You Entered Is ".$mail; ?> You are right, sorry. Didn't pay attention to that, I just copied his coded and change the part for echo of the variable. Was in a hurry and i neglected the code itself :S Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836381 Share on other sites More sharing options...
Ken2k7 Posted May 18, 2009 Share Posted May 18, 2009 There are issues with your code Dathremar. 1. The trim function is being used on a variable that has already been trimmed 2. There is no need to use an else statement after an exit function. The script will terminate if the condition is not met. Thirdly you code should check for a valid email address not just if the field is empty. <?php // get posted data into local variables $mail = trim($_POST['mail']); if(!eregi("^[^@]{1,64}@[^@]{1,255}$", $mail)) { exit("Please enter a valid E-Mail address."); } echo "The E-Mail You Entered Is ".$mail; ?> preg > ereg Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836400 Share on other sites More sharing options...
LindaD Posted May 18, 2009 Author Share Posted May 18, 2009 There are issues with your code Dathremar. 1. The trim function is being used on a variable that has already been trimmed 2. There is no need to use an else statement after an exit function. The script will terminate if the condition is not met. Thirdly you code should check for a valid email address not just if the field is empty. <?php // get posted data into local variables $mail = trim($_POST['mail']); if(!eregi("^[^@]{1,64}@[^@]{1,255}$", $mail)) { exit("Please enter a valid E-Mail address."); } echo "The E-Mail You Entered Is ".$mail; ?> Hi Neil, thanks for the sample help.. what I'm trying to do is make firstname, lastname, mail, and pass required fields then when form submitted it creates a link like this: www.site.com/index.php?firstname=xxx&lastname=xxx&mail=xxx&pass=xxxx 'click here to continue'... if any of the fields left blank it says go back and fill in all fields. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836543 Share on other sites More sharing options...
JonnoTheDev Posted August 11, 2009 Share Posted August 11, 2009 Why would you create a url string that contains all of the input data? This would be easily open to abuse. If you want the data to remain persistent then either make the click to continue button a form submit, passing the user data into the form as hidden fields, or once the data has been validated then store it in session variables. Quote Link to comment https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-895631 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.