Jump to content

Recommended Posts

Hi,

I am a beginner in php. I speak little english  I got the the script on form to email but I have problems with him. Please help with that?

1.  Form are uploaded but immediately sends unfilled on email. 

2.  Immediately after loaded and sent to the e-mail page appears thanking although has not been filled. Is perhaps a better to control of

       fulfillment of important data ?

3. How to do after sending the form redirection to the new webpage with the results:

                                                                          a) Form was sent - web page I have already made -  the need to insert link to a php.

                                                                          b) Error + error list - web page I have already made -  the need to insert link to a php.

Thank you all in advance for your help with the addition of a script !!!

I enclose a script:

 

<?php
 
$EmailFrom = "info@my mail.co.uk";
$EmailTo = "info@my mail.co.uk";
$Subject = "Info";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
 
$validationOK=true;
if (!$validationOK) {
  echo "please check your details";
  header("Location: http://my webpage/testform.php");
  exit;
}
 
 
 
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
 
 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
 
 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"1;URL=thanks.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"1;URL=thanks.html\">";
}
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title></title>
  
  </head>
  <body>
  
    <form action="testform.asp" method="post">
 
<div>
<input name="_recipients" type="hidden" value="info@\\web-123win\winpackage23\my webpage.co.uk\www.my webpage.co.uk\web\content\fc\setup_script.cgi" />
<input name="_requiredFields" type="hidden" value="Name,Email,Message" />
<input name="_envars" type="hidden" value="HTTP_USER_AGENT,REMOTE_ADDR" />
<input name="_returnUrl" type="hidden" value="default.asp" />
<input name="_continueUrl" type="hidden" value="default.asp" />
</div>
 
<table>
 
<tr>
<th align="left">Name:</th>
<td><input name="Name" type="text" size="50" /></td>
</tr>
<tr>
<th align="left">Email Address:</th>
<td><input name="Email" type="text" size="50" /></td>
</tr>
 
<tr>
<th align="left">Comments:</th>
<td><input name="Message" type="text" size="50" /></td>
</tr>
<tr><td colspan="2"><b>To prevent spam, please enter the text from the following picture:</b></td></tr>
</table>
  <div  id = "rocaptcha_placeholder" ></div> 
<script  type = "text/javascript"  src = "http://rocaptcha.com/api/js/?key=my private key" ></script> 
<script  type = "text/javascript" > 
RoCaptcha . init ( "rocaptcha_placeholder" ); 
</script>
<p><input class="button" type="submit" value="Submit" />
<input class="button" type="reset" value="Clear" /></p>
 
  </form>
  </body>
</html>
Edited by cyberRobot
added [code][/code] tags

Look at your script!!  YOu blindly create php vars using stuff that may or may not exist.  Then you output the email and send a success message.  Where is you logic?  Where do you even check if you have $_POST vars? 

 

You obviously are learning, but you also are obviously not used to programming in any language.  YOu have to look at your code and know what it is doing and be sure that is what you want it to do.

 

Start your script at the top by checking if a specific POST variable exists.  I like to use the button value that the user clicks to submit the form.  So if your submit button is named "btn" and the value of the button is 'Submit', then my first line would be :

if (isset($_POST['btn']) && $_POST['btn'] == 'Submit')

{

    continue with form processing and email

    build a success or failure message such as $msg = "???";

}

else

{

   handle the first time thru this script of some other submit button process (Cancel or Return??)

}

DisplayPage();   //  call a function that displays all of my html code - the form and any messages.

exit();

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.