Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/
Share on other sites

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;
?>

Link to comment
https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836379
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836381
Share on other sites

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 :P

Link to comment
https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836400
Share on other sites

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  ;D

Link to comment
https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-836543
Share on other sites

  • 2 months later...

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.

Link to comment
https://forums.phpfreaks.com/topic/158571-adding-_post-in-echo/#findComment-895631
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.