|
|
#1 (permalink) |
|
Registered User
Super #1
Joined in Mar 2005
Lives in Washougal, WA
1,302 posts
Gave thanks: 23
Thanked 39 times
|
Calling MarkRH
In regards to this PHP Random Text
Having a bit of trouble implementing the code you posted, your assistance would be greatly appreciated, thanks. Have a separate file named imgver.php in place. Form is here http://www.wmcintosh.com/contact.php email.php Code:
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$receiverMail= "email removed";
$name= trim(strip_tags(stripslashes($_POST['name'])));
$email= trim(strip_tags(stripslashes($_POST['email'])));
$subject= trim(strip_tags(stripslashes($_POST['subject'])));
$msg= trim(strip_tags($_POST['msg']));
$code = trim(strip_tags(stripslashes($_POST['code'])));
$ip= getenv("REMOTE_ADDR");
$msgformat= "From: $name ($ip)\nEmail: $email\n\n$msg";
// VALIDATION
if(empty($name) || empty($email) || empty($subject) || empty($msg) || empty($code)) {
echo '<div class="error">Unable to send email: missing field or fields.</div>';
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo '<div class="error">Unable to send email: invalid email address.</div>';
}else{
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo '<div class="success">Email sent successfully. Thank you.</div>';
}
}
?>
Code:
<form action="http://www.wmcintosh.com/contact.php" method="post">
<table border="0" align="center" cellpadding="2" cellspacing="0" width="75%">
<tr>
<td colspan="2" align="center" valign="middle"><?php include('xxxxxxxx/email.php'); ?></td><tr>
<td align="right" valign="middle"><b>Name:</b></td><td align="left"><input type="text" name="name" size="50" class="input" value="<?php echo $_POST['name']; ?>"></td><tr>
<td align="right" valign="middle"><b>Email:</b></td><td align="left"><input type="text" name="email" size="50" class="input" value="<?php echo $_POST['email']; ?>"></td><tr>
<td align="right" valign="middle"><b>Subject:</b></td><td align="left"><input type="text" name="subject" size="50" class="input" value="<?php echo $_POST['subject']; ?>"></td><tr>
<td align="right" valign="top"><b>Comment:</b></td><td align="left"><textarea rows="8" cols="38" name="msg" class="input"><?php echo $_POST['msg']; ?></textarea></td><tr>
<td align="right" valign="middle"><b>Verify:</b></td><td align="left"> [like img or text to be here] <input type="text" name="code" size="10" class="input" value="<?php echo $_POST['code']; ?>"></td><tr>
<td align="right" valign="middle"><br /></td><td align="left"><input type="submit" style="width: 100px;" value="Send!"> <?php echo $txt['contactformnote']; ?></td><tr>
<td align="right" valign="middle"><br /></td><td align="left"><br /></td>
</tr>
</table>
</form>
|
|
|
|
|
|
#2 (permalink) |
|
Registered User
Super #1
Joined in Mar 2005
Lives in Washougal, WA
1,302 posts
Gave thanks: 23
Thanked 39 times
|
I combined contact form with email.php together if that makes it easier to implement, easy to switch back if necessary (as posted above).
Code:
<?php echo '<form action="http://www.wmcintosh.com/contact.php" method="post">
<table border="0" align="center" cellpadding="2" cellspacing="0" width="75%">
<tr>
<td colspan="2" align="center" valign="middle">';
if($_SERVER['REQUEST_METHOD'] == "POST") {
$receiverMail= "my email removed";
$name= trim(strip_tags(stripslashes($_POST['name'])));
$email= trim(strip_tags(stripslashes($_POST['email'])));
$website = trim(strip_tags($_POST['website']));
$subject= trim(strip_tags(stripslashes($_POST['subject'])));
$msg= trim(strip_tags($_POST['msg']));
$code = trim(strip_tags(stripslashes($_POST['code'])));
$ip= getenv("REMOTE_ADDR");
$msgformat= "From: $name ($ip)\nEmail: $email\nWebsite: $website\n\n$msg";
// VALIDATION
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo '<div class="error">Unable to send email: missing field or fields.</div>';
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo '<div class="error">Unable to send email: invalid email address.</div>';
}else{
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo '<div class="success">Email sent successfully. Thank you.</div>';
}
} echo '</td><tr>
<td align="right" valign="middle"><br></td><td align="left">' . $txt['contactformnote'] . '</td><tr>
<td align="right" valign="middle"><b>Name:</b></td><td align="left"><input type="text" name="name" size="50" class="input" value="' . $_POST['name'] . '"></td><tr>
<td align="right" valign="middle"><b>Email:</b></td><td align="left"><input type="text" name="email" size="50" class="input" value="' . $_POST['email'] . '"></td><tr>
<td align="right" valign="middle">Website:</td><td align="left"><input type="text" name="website" size="50" class="input" value="' . $_POST['website'] . '"></td><tr>
<td align="right" valign="middle"><b>Subject:</b></td><td align="left"><input type="text" name="subject" size="50" class="input" value="' . $_POST['subject'] . '"></td><tr>
<td align="right" valign="top"><b>Comment:</b></td><td align="left"><textarea rows="8" cols="38" name="msg" class="input">' . $_POST['msg'] . '</textarea></td><tr>
<td align="right" valign="middle"><b>Verify:</b></td><td align="left">(verify been disabled)</td><tr>
<td align="right" valign="middle"><br></td><td align="left"><input type="submit" style="width: 100px;" value="Send!" disabled="disabled"></td><tr>
<td align="right" valign="middle"><br></td><td align="left"><br></td>
</tr>
</table>
</form>' . "\n";
?>
|
|
|
|
|
|
#3 (permalink) |
|
Race Surpass
Super #1
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,218 posts
Gave thanks: 18
Thanked 86 times
|
Sorry for taking so long to see this.. but in that portion of the contact form you need to add the code:
Code:
<P> I am a human code (case sensitive): <IMG SRC="php/human_code.php" WIDTH="60" HEIGHT="20" BORDER="1" ALIGN="middle" ALT="human code"> (If you can't tell what some of the characters are, just reload the page by right-clicking somewhere on this page and select the <STRONG>refresh</STRONG> menu option and let it generate a new sequence). </p> Inside your email.php script, add the following bit of verification code: PHP Code:
Hopefully that's clear as mud.. brain's kinda fried after work. ![]()
__________________
|
|
|
|
| This user thanks MarkRH for this great post! | wgm (November 5th, 2007) |
|
|
#4 (permalink) |
|
Registered User
Super #1
Joined in Mar 2005
Lives in Washougal, WA
1,302 posts
Gave thanks: 23
Thanked 39 times
|
No problem MarkRH, you were either busy or doing something else, after all there if life beyond forums.
Been added http://www.wmcintosh.com/contact.php Hope its works like it should (though I did reword it some, not the code). I really appreciate the assistance, thank you. |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Super #1
Joined in Mar 2005
Lives in Washougal, WA
1,302 posts
Gave thanks: 23
Thanked 39 times
|
I tried to modify the code for random numbers and letters only.
What I was going for was to display 48 to 57, 65 to 90 and 97 to 122 randomly ( http://www.asciitable.com/ ), but failed in my attempts. Thanks, any information would help. |
|
|
|
|
|
#6 (permalink) |
|
Race Surpass
Super #1
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,218 posts
Gave thanks: 18
Thanked 86 times
|
Try this modified human_code.php:
PHP Code:
__________________
|
|
|
|
| This user thanks MarkRH for this great post! | wgm (November 10th, 2007) |
|
|
#7 (permalink) |
|
Registered User
Super #1
Joined in Mar 2005
Lives in Washougal, WA
1,302 posts
Gave thanks: 23
Thanked 39 times
|
Really really appreciate the help, thank you very much, appears to work just fine.
Okay I won't bug you anymore, just wish my brain would comprehend PHP more. |
|
|
|