homepage Welcome to WebmasterWorld Guest from 23.22.217.122
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Form Submission not working
deceptionx




msg:4644105
 5:19 am on Feb 11, 2014 (gmt 0)

I found the thread [webmasterworld.com...] for help but it is too old to ask a question.

I pretty much copied and fixed what people said in that thread but my form is still not submitting correctly.

Form Code:

<form action="result.php" method="post" enctype="text/plain" name="form1">
<table width="500" border="0" align="center" cellspacing="0">
<tr>
<td>Name:</td>
<td><input name="name" type="text" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="email" type="text" size="30" maxlength="50" placeholder="example@domain.com"></td>
</tr>
<tr>
<td>Phone:</td>
<td><input name="phone" type="text" size="30" maxlength="20"></td>
</tr>
<tr>
<td>Inquiry type:</td>
<td><select name="type">
<option value="1" selected>Residential Inquiry</option>
<option value="2">Small Business Inquiry</option>
<option value="3">Web Design Inquiry</option>
<option value="4">Existing Client Inquiry</option>
</select></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name="message" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="submit" type="submit" value="Submit" />
<input name="reset" type="reset" value="Reset" /></td>
</tr>
</table>
</form>


PHP Code:

<?php

$name = $_POST['name'];
$visitor_email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['type'];
$message = $_POST['message'];

if(IsInjected($visitor_email))
{
echo "Bad email value!";
exit;
}

$email_from = 'example@example.com';//<== update the email address
$email_subject = "$subject";
$email_body = "$message" + "phone";

$to = "example@example.com"; //<== update the email address
$headers = "From: $email_from \r\n";
$headers = "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: http://www.example.com/example.html');


// Function to validate against any email injection attempts
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;
}
}

?>


When I hit submit on the web page it just directs to a blank page and I'm not getting an email sent where I designated it to send one.

Also should these two emails be two different emails or can they be the same?

$email_from = 'example@example.com';//<== update the email

$to = "example@example.com"; //<== update the email address

 

deceptionx




msg:4644274
 4:54 pm on Feb 11, 2014 (gmt 0)

I got it to work.

deceptionx




msg:4644275
 4:56 pm on Feb 11, 2014 (gmt 0)

I got it working, thanks anyway.

coopster




msg:4644307
 7:39 pm on Feb 11, 2014 (gmt 0)

Welcome to WebmasterWorld, deceptionx.

Glad you got it sorted! What was the issue?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved