Jump to content
schmitta

webmail to email problem

Recommended Posts

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 = 'schmitt_alvin@yahoo.com';
$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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.