PHP Form Mail Help

How To's, Questions, and Solutions for problems. This covers anything from computer hardware problems to software recommendations to tutorials for various software programs.

Note: Neither Gametoast nor any of its members/visitors are responsible for any damage to your computer as a result from advice given in this forum. Follow advice at your own risk and be sure to back up any important files.

Moderator: Moderators

Post Reply
User avatar
Dohnutt
Hoth Battle Chief
Hoth Battle Chief
Posts: 3248
Joined: Sun Aug 20, 2006 9:25 am
Contact:

PHP Form Mail Help

Post by Dohnutt »

Ok, so I found a tutorial for a PHP form mailer, here.

And it didn't work. So I'll post exactly what I posted there. Nobody has answered me, though. So, I thought maybe I'd get some more help here.



Ok, I'm trying to make three forms.
The first is a song request (this is for an online radio), in which I just want it to send an email to my friend. It is here.
As you can see, it's not exactly working. Theres an error.

request.php:

Code: Select all

<? else
{?>

    	<form method="post" action="songrequest.php">
	&nbsp;<b>Name:</b>&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="name" size=60><br>
	&nbsp;<b>Song:</b>&nbsp;&nbsp;
	<INPUT TYPE="TEXT" NAME="song" size=60>
	<p align="center"><input type="submit" name="submit" value="submit">
	<input type="reset" name="clear" value="clear"></p>
    	</form>

<? }?>
So, it's told to go to songrequest.php:

Code: Select all

<? //initilize PHP
if($submit) //If submit is hit
{
    mail("[b]email removed for privacy[/b]", "$name", "$song");
}?>

Thank you! <a href="index.php">Click here</a> to go back to Revolution Radio.

And then theres the Contact Us page. I want 2 forms; one for website help, and one for radio help. I just want name, email, and comments for both of them. It's here. Yes, another error. Similar to the other.

contact.php Website Form:

Code: Select all

<? else
{?>

    	<form method="post" action="websitecontact.php">
	&nbsp;<b>Name:</b>&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="name" size=60><br>
	&nbsp;<b>E-mail:</b>
	<INPUT TYPE="TEXT" NAME="email" size=60><br>
	&nbsp;<b>Comments:</b>&nbsp;<TEXTAREA NAME="comments" ROWS=10 COLS=30></TEXTAREA>
	<p align="center"><input type="submit" name="submit" value="submit">
	<input type="reset" name="clear" value="clear"></p>
    	</form>

<? }?>
contact.php Radio Form:

Code: Select all

<? else
{?>

    	<form method="post" action="radiocontact.php">
	&nbsp;<b>Name:</b>&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="name" size=60><br>
	&nbsp;<b>E-mail:</b>
	<INPUT TYPE="TEXT" NAME="email" size=60><br>
	&nbsp;<b>Comments:</b>&nbsp;<TEXTAREA NAME="comments" ROWS=10 COLS=30></TEXTAREA>
	<p align="center"><input type="submit" name="submit" value="submit">
	<input type="reset" name="clear" value="clear"></p>
    	</form>

<? }?>
And they point towards two different files; radiocontact.php:

Code: Select all

<? //initilize PHP
if($submit) //If submit is hit
{
    mail("[b]email removed for privacy[/b]", "$name", "$comments" , "$email");
}?>

Thank you!

<a href="index.php">Click here</a> to go back to Revolution Radio.
...and websitecontact.php:

Code: Select all

<? //initilize PHP
if($submit) //If submit is hit
{
    mail("[b]email removed for privacy[/b]", "$name", "$comments" , "$email");
}?>

Thank you!

<a href="index.php">Click here</a> to go back to Revolution Radio.


I'd just like to say that I'm not a very experience PHP'er. In fact, I have VERY little knowledge. I'm a copy/paste type person. Anyways, got any ideas? I appreciate it a whole bunch.


Thanks guys :)
User avatar
swbf_lase
Major General
Major General
Posts: 647
Joined: Fri Jul 08, 2005 7:07 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: 127.0.0.1:465
Contact:

RE: PHP Form Mail Help

Post by swbf_lase »

Ok, this is whats wrong in request.php you need to change it to,

Code: Select all

<?else
{

     print "  <form method="post" action="songrequest.php">
   &nbsp;<b>Name:</b>&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="name" size=60><br>
   &nbsp;<b>Song:</b>&nbsp;&nbsp;
   <INPUT TYPE="TEXT" NAME="song" size=60>
   <p align="center"><input type="submit" name="submit" value="submit">
   <input type="reset" name="clear" value="clear"></p>
       </form>";
 }?>
Basically by adding print to the other forms as well, it'll work. But, also I see no if statement for else to work with! So thats also why its not working. I'm not exactly sure where your if statement is so if you could show me that...

Could you please post the WHOLE request.php? I need to see the rest of it...

EDIT: Actually, can you just PM me the whole source package?
User avatar
Dohnutt
Hoth Battle Chief
Hoth Battle Chief
Posts: 3248
Joined: Sun Aug 20, 2006 9:25 am
Contact:

RE: PHP Form Mail Help

Post by Dohnutt »

No problem. I'll PM it to you now. By source package, you mean all of the files attached to it through php, right?
User avatar
swbf_lase
Major General
Major General
Posts: 647
Joined: Fri Jul 08, 2005 7:07 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: 127.0.0.1:465
Contact:

RE: PHP Form Mail Help

Post by swbf_lase »

yep.
User avatar
Dohnutt
Hoth Battle Chief
Hoth Battle Chief
Posts: 3248
Joined: Sun Aug 20, 2006 9:25 am
Contact:

RE: PHP Form Mail Help

Post by Dohnutt »

Ok, I sent it yesterday.
Post Reply