schmitta Posted October 20, 2018 Share Posted October 20, 2018 I am trying to send email from a website. I have the code in noaccess.php that I am trying to load from my website. I acquire the data to send from a form. When SEND is hit I want noaccess.php to be loaded. I am a total php newbie. What I need would be a WAIT statement to have the website code executor wait until SEND is hit. What I have is as follows: This is the code in the website: <center> For more information please fill out the following form: <br> <!-- <form action="http://www.alvinpschmitt.com/noaccess.php" name="noaccess" method="POST"> --> <form action="form-to-email.php" name="noaccess" method="POST"> Name: <input type="text" name="Name" /><br> Email: <input type="text" name="Email" /><br> Phone: <input type="text" name="Phone" /><br> <input type="button" name="subj1" value="Eagle CAD Information" /> <input type="button" name="subj2" value="Consulting Information" /> <input type="submit" value="SEND"/> </form> </center> <?php while(!isset($_POST['SEND'])) { sleep(1); } header("Location: http://www.alvinpschmitt.com/noaccess.php"); //exit; ?> And then the noaccess.php file has: <html><head></head><body> <?php $name = $_POST['Name']; $email = $_POST['Email']; $phone = $_POST['Phone']; $to = '[email protected]'; $subject = $_POST['subj1']." ".$_POST['subj2']; $header = "From: $to\r\n"; $body = "Name: $name\n". "Email: $email\n". "Phone: $phone\n"; //Validate first if(empty($name)||empty($email)) { echo "Name and email are mandatory!"; exit; } if(IsInjected($email)) { echo "Bad email value!"; exit; } mail($to,$subject,$body,$header); //header('Location: http://www.alvinpschmitt.com/thankyou.html'); exit; function IsInjected($str) { $injections =array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|',$injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> </body> </html> The website circles in the browser using up some kind of resource and then no longer allows me to access the website because I used up all my resource. I need to get this working so I can make money to live on. Thank you for helping me. Quote Link to comment https://forums.phpfreaks.com/topic/307800-webmail-to-email-problem/ Share on other sites More sharing options...
ginerjm Posted October 20, 2018 Share Posted October 20, 2018 There is no "wait" - you send data to the client and exit the script. Then the client (after the user does his thing) sends back the data ($_GET or $_POST) to the script named in the form's action attribute and that script processes the incoming data (hopefully in $_POST). If you like the input you proceed to send off the email. If you don't like it you return the same form with the data in the inputs and let the user correct. You should be able to do this all with one script to make it easier to re-send the form back out with an error message. Quote Link to comment https://forums.phpfreaks.com/topic/307800-webmail-to-email-problem/#findComment-1561661 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.