What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » (php) Contact Us form

(php) Contact Us form
Author: Message:
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
O.P. Huh?  (php) Contact Us form
Hi, for some reason this contact form that I'm working on won't work, can someone please try to fix it?

contact.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Messenger Crap - Contact Us</title>
</head>
<body>

<form action="sendmail.php" method="POST">

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

Email:<br />
<input type="text" name="email" size="35" />
<p>
</p>
<p>
</p>

Message:
<br />
<textarea name="message" rows="4" cols="40"></textarea>
<br />
<p>
<input type="submit" value="Send" style='width:100px;' />


<input type="reset" value="Clear" style='width:100px;' />
</form>

</body>
</html>






sendmail.php:

<?php
/*Here we are going to declare the variables*/
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $message";
$recipient = "msgcrap@live.com";
$subject = "Contact Us - Messenger Crap";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
echo "Thank You!";
?>


--------------------------------------------------------------------------------------------------






Or could someone maybe please try make another one?

This post was edited on 11-13-2006 at 09:18 AM by davidpolitis.
11-13-2006 07:24 AM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: (php) Contact Us form
Well, the script sucks, and it's not secure, but I'm going to ignore that. :p

What happens when you try to send a message?
11-13-2006 05:34 PM
Profile PM Web Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
O.P. RE: (php) Contact Us form
Yer, lol.

Well, the sendmail.php script works, but when I try to send an email using contact.php is just doesn't send anything
11-13-2006 07:37 PM
Profile PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: (php) Contact Us form
Make this into one file:
code:
<?php
if (isset($_POST['submit'])) {
/*Here we are going to declare the variables*/
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $message";
$recipient = "msgcrap@live.com";
$subject = "Contact Us - Messenger Crap";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
echo "Thank You!";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Messenger Crap - Contact Us</title>
</head>
<body>

<form action=" " method="POST">

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

Email:<br />
<input type="text" name="email" size="35" />
<p>
</p>
<p>
</p>

Message:
<br />
<textarea name="message" rows="4" cols="40"></textarea>
<br />
<p>
<input type="submit" value="Send" style='width:100px;' />


<input type="reset" value="Clear" style='width:100px;' />
<input type="submit" name="submit" value="Login" />
<input type="hidden" name="submit" value="TRUE" />
</form>

</body>
</html>

I have not tested this but it should work.

This post was edited on 11-13-2006 at 08:11 PM by Nathan.
Touch Innovation - touch friendly programs/applications for the windows mobile!


11-13-2006 07:57 PM
Profile E-Mail PM Web Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: (php) Contact Us form
quote:
Originally posted by Nathan
Make this into one file:
code:
<?php
if (isset($_POST['submit'])) {
/*Here we are going to declare the variables*/
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $message";
$recipient = "msgcrap@live.com";
$subject = "Contact Us - Messenger Crap";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
echo "Thank You!";
i would let it die here...that looks better...
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Messenger Crap - Contact Us</title>
</head>
<body>

<form action=" " method="POST">

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

Email:<br />
<input type="text" name="email" size="35" />
<p>
</p>
<p>
</p>

Message:
<br />
<textarea name="message" rows="4" cols="40"></textarea>
<br />
<p>
<input type="submit" value="Send" style='width:100px;' />


<input type="reset" value="Clear" style='width:100px;' />
<input type="submit" name="submit" value="Login" />
<input type="hidden" name="submit" value="TRUE" />
</form>

</body>
</html>

I have not tested this but it should work.
11-14-2006 12:10 AM
Profile E-Mail PM Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
O.P. RE: (php) Contact Us form
Thanks heaps, but for some reason it does not show the message I type in. :(

EDIT: I found a working contact script & edited it, yay! :)


Got any ideas to make the code below more secure?


------------------------------------------------------------------------------------------------------

<?php
if(isset($_POST['submit'])) {

    $to = "msgcrap@live.com";
    $subject = "Messenger Crap - Contact Us";
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];
    $message = $_POST['message'];

   
    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message\n";

    echo "Data has been submitted to $to!";
    mail($to, $subject, $body);
   

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Messenger Crap - Contact Us</title>
</head>
<body>

<form action=" " method="POST">

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

Email:<br />
<input type="text" name="email" size="35" />
<p>
</p>
<p>
</p>

Message:
<br />
<textarea name="message" rows="4" cols="40"></textarea>
<br />
<p>

<input type="submit" value="Submit" name="submit" style='width:100px;' />

<input type="reset" value="Clear" style='width:100px;' />

</form>

</body>
</html>

This post was edited on 11-14-2006 at 05:23 AM by davidpolitis.
11-14-2006 04:51 AM
Profile PM Find Quote Report
surfichris
Former Admin
*****

Avatar

Posts: 2365
Reputation: 81
Joined: Mar 2002
RE: (php) Contact Us form
You need to ensure you're only accepting valid email addresses.

http://www.totallyphp.co.uk/code/validate_an_emai...ar_expressions.htm

It's also vulnerable to spam - people can continue to resubmit it etc.

I'd recommend implementing freecap, a PHP based Captcha library. A captcha is basically a server generated image containing a string that the user is required to enter before they can perform an action - protects against automated submissions etc.

freecap: http://www.puremango.co.uk/cm_php_captcha_script_113.php
11-16-2006 12:19 PM
Profile PM Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
O.P. RE: (php) Contact Us form
Yer, thnx. I'm gonna try to make it better during the holdays because end of year exams are coming up.

Also, does anyone know how to make the sender of the email be the email address the person typed in?

This post was edited on 11-17-2006 at 05:21 AM by davidpolitis.
11-17-2006 05:19 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On