craigglenn
Technical User
I have searched high and low and can't seem to find the solution that fits my situation.
Wordpress 3.X
PHP 5.x
MySql 5.0
URL with Post Form:
Problem: The form works, the PHP loads data into my table, the email fires (still working on some formatting issues with that) but after hitting submit it goes to a blank page and does not return to the original page. Even though everything worked. HTML and PHP below. Thanks in advance for your help.
Form html
<form action="/insert_contact.php" method="post">
<table border="0" width="100%">
<tbody>
<tr>
<td>Name:</td>
</tr>
<tr>
<td><input id="name" name="name" type="text" /></td>
</tr>
<tr>
<td>Email Address:</td>
</tr>
<tr>
<td><input id="email" name="email" type="text" /></td>
</tr>
<tr>
<td>Comment:</td>
</tr>
<tr>
<td><textarea name="comment" rows="5" cols="60"></textarea></td>
</tr>
<tr>
<td><input id="Submit!" name="Submit!" type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
PHP
<?php
$con = mysql_connect('hir1028411423720.db.6837474.hostedresource.com','UserName','Password');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('hir1028411423720', $con);
$_name = mysql_real_escape_string($_POST["name"]);
$_email = mysql_real_escape_string($_POST["email"]);
$_comment = mysql_real_escape_string($_POST["comment"]);
$regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
$sql = "INSERT INTO wp_contact (name, email, comment)
VALUES ('$_name','$_email','$_comment')";
if ($_email==NULL)
{
die('Email is Required: Click the back button on your browser to return and try again.' . mysql_error());
}
if (preg_match($regexp, $_email))
{
mysql_query($sql, $con);
}
else
{
die('Invalid Email Address! Please enter a valid email address. Click the back button on your browser to return' . mysql_error());
}
mysql_close($con);
$to = "craig.glenn@yahoo.com";
$subject = "New Comment on HireMaureen.com";
$message = $_comment;
$from = $_email;
$headers = "From: $_name" . "\r\n" . "Email: $_email";
mail($to,$subject,$message,$headers);
exit;
?>
"You can have anything in life you want if you help enough people get what they want"
Zig Ziggler
Wordpress 3.X
PHP 5.x
MySql 5.0
URL with Post Form:
Problem: The form works, the PHP loads data into my table, the email fires (still working on some formatting issues with that) but after hitting submit it goes to a blank page and does not return to the original page. Even though everything worked. HTML and PHP below. Thanks in advance for your help.
Form html
<form action="/insert_contact.php" method="post">
<table border="0" width="100%">
<tbody>
<tr>
<td>Name:</td>
</tr>
<tr>
<td><input id="name" name="name" type="text" /></td>
</tr>
<tr>
<td>Email Address:</td>
</tr>
<tr>
<td><input id="email" name="email" type="text" /></td>
</tr>
<tr>
<td>Comment:</td>
</tr>
<tr>
<td><textarea name="comment" rows="5" cols="60"></textarea></td>
</tr>
<tr>
<td><input id="Submit!" name="Submit!" type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
PHP
<?php
$con = mysql_connect('hir1028411423720.db.6837474.hostedresource.com','UserName','Password');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('hir1028411423720', $con);
$_name = mysql_real_escape_string($_POST["name"]);
$_email = mysql_real_escape_string($_POST["email"]);
$_comment = mysql_real_escape_string($_POST["comment"]);
$regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
$sql = "INSERT INTO wp_contact (name, email, comment)
VALUES ('$_name','$_email','$_comment')";
if ($_email==NULL)
{
die('Email is Required: Click the back button on your browser to return and try again.' . mysql_error());
}
if (preg_match($regexp, $_email))
{
mysql_query($sql, $con);
}
else
{
die('Invalid Email Address! Please enter a valid email address. Click the back button on your browser to return' . mysql_error());
}
mysql_close($con);
$to = "craig.glenn@yahoo.com";
$subject = "New Comment on HireMaureen.com";
$message = $_comment;
$from = $_email;
$headers = "From: $_name" . "\r\n" . "Email: $_email";
mail($to,$subject,$message,$headers);
exit;
?>
"You can have anything in life you want if you help enough people get what they want"
Zig Ziggler