...

View Full Version : php select email form



itssawyer
05-10-2009, 04:00 PM
i am trying to make an email form that the user will go to and put in there "username" select the category for there article to submit is in(which will select which email to send it to) and then put in there title and the actual article. I had gotten everything to work except the username and title would not show up. and now that i have tried to get them to show up in the email, nothing is working now, the email is not even being sent. any help?


<?php
$to = $_REQUEST['selectemail'];
$title = $_REQUEST['title'];
$article= $_REQUEST['article'];
$username = $_REQUEST['username'];
$subject = "$title ARTICLE SUBMISSION";
$email = $_REQUEST['email'] ;
$message = username: $username article: $article ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your article was submited!<br> <a href='http://www.thesqrl.com/windowpop.html'>Send another article</a>"; }
else
{print "We encountered an error recieving your article! Please email technical support."; }
?>


<html>
<head>
<title>ARTICLE SUBMISSION </title>



</head>
<body bgcolor="#99ccff"><p align="center">
<img src="popupheader.png">
</p>

<form action="sendarticle.php">
<font color="red" face="tahoma"><u>*Articles are subject to spell checks*</u><br></font>
USERNAME:<br><input type="text" name="username" size="50"><BR>

EMAIL:<br><input type="text" name="email" size="50"><BR>

CHOOSE A CATEGORY:<BR>
<select name="selectemail">
<option value="mattjamessawyer@hotmail.com">WORLD NEWS</option>
<option value="news.us@thesqrl.com">US NEWS</option>
<option value="news.politics@thesqrl.com">POLITICS</option>
<option value="news.business@thesqrl.com">BUSINESS</option>
<option value="news.culture@thesqrl.com">ART & CULTURE</option>
<option value="news.tech@thesqrl.com">TECH</option>
<option value="news.sports@thesqrl.com">SPORTS</option>
<option value="news.misc@thesqrl.com">MISCELLANEOUS</option>
</select>
<hr width="50%"></hr>

<u>ARTICLE</u><p>

ARTICLE TITLE:<br>
<input type="text" name="title" size="50"><BR>

ARTICLE
<textarea rows="15" cols="65" name="article"></textarea><p>

<center>



<input type="submit" value="SUBMIT ARTICLE" />



news.world@thesqrl.com






</body>
</html>

venegal
05-10-2009, 04:03 PM
$message has to be a string:


$message = "username: $username article: $article";

itssawyer
05-10-2009, 04:08 PM
ok, thank you for that. i corrected it, but it is still not working. The rest of the code now is.


<?php
$to = $_REQUEST['selectemail'];
$title = $_REQUEST['title'];
$article= $_REQUEST['article'];
$username = $_REQUEST['username'];
$subject = "$title ARTICLE SUBMISSION";
$email = $_REQUEST['email'] ;
$message = "username: $username article: $article" ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your article was submited!<br> <a href='http://www.thesqrl.com/windowpop.html'>Send another article</a>"; }
else
{print "We encountered an error recieving your article! Please email technical support."; }
?>

any other ideas?
thanks

venegal
05-10-2009, 04:26 PM
You wrote you already got it to work, except for the username thing, so I am going to assume that PHP on your server is already configured to send mail.

Other than that, your code works for me.

I would change

<form action="sendarticle.php">
to

<form action="sendarticle.php" method="post">
though.

itssawyer
05-10-2009, 04:51 PM
thanks alot, its all working now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum