Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Submit Button
#1
Alright, so I made (copy and pasted) a Submit / Suggestion box for my website but I have no idea how .asp works. How would I receive the information that a user types in the box?
Here's the code:
Code:
<form name="input" action="html_form_action.asp" method="get">
Suggestions:<br> <input type="text" name="user" /><br>
<input type="submit" value="Submit" />
</form>

If not, does anyone have a simple form mail script?
[Image: fixedt.png]
Reply
#2
Yeah,
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Andrey's Email form</title>
</head>
<body>

<form method="post" action="sendemail.php">

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send!" />
<br />
</form>

</body>
</html>

That's the contact form you want to use, for example "Contactus.php" or whatever.

This is sendmail.php, the script itself.



Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>


<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$subject = $text;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("claw@asdf.com", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo Andrey ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php"> Next Page </a>
</p>

</body>
</html>

It's rather basic and self explanatory. You can also obviously tell where to edit and customize it as you see. It's good to learn how it works too Smile

EDIT: Oh, i'll also give you a small explanation. It basically just sends the information the user types in via POST and then the sendmail.php uses the actual code. Contact.php is basically the input values only.


In contact.php we have:


<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />

This will be just an example. Then, that creates the form to be named "visitor" as a variable like situation. When it goes into sendmail.php, it'll use that to generate the email using the "visitor" variable defined in sendmail as "$visitor = $_POST['visitor']; ".

Simple, right? Big Grin

The extra code:

'<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>'

Is to get the users IP information, etc. It's not always necessary but useful.


Also, I just made it for a friend so you'll want to customize a lot of it to your own uses obviously. It's in PHP too, not ASP. I wouldn't know how this works in ASP exactly anymore.

Enjoy
Brandon
Reply
#3
Thanks a lot for this! Works perfectly. :]
[Image: fixedt.png]
Reply
#4
Lawl .. i use that script Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What File Would I Modify For New Button On My Main Page schneweis 2 876 12-23-2010, 10:20 PM
Last Post: Bourd
  Auto Click Button Scorpion 1 1,977 11-06-2009, 09:00 PM
Last Post: Gaijin
  How to create Button MouseOver effect Gaijin 4 3,863 10-11-2009, 04:23 AM
Last Post: Gaijin

Forum Jump:


Users browsing this thread: 1 Guest(s)