Forum Moderators: coopster

Message Too Old, No Replies

Php form not sending mail

Php help please

         

xtremetimes

8:19 am on Jul 3, 2003 (gmt 0)

10+ Year Member



yes i have a phpnuke site and i work and design my templates rather well for it, but i wanted to create a module for a join form submit by e-mail i created and did the script well and i didnt recieve any error but upon submitting i recieved no e-mail i am pasting the code and will hope for some help. thanks

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

<?php
########
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");

}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 0;
OpenTable();
echo"<center><form method=\"POST\">"
. " <p>&nbsp;</p>"
. " <table cellSpacing=\"0\" cellPadding=\"0\" border=\"0\" width=\"562\">"

<modnote>removed excessive code (as per charter) for form data

. " <textarea name=\"message\" rows=\"5\" wrap=\"virtual\" cols=\"35\"></textarea></td>"
. " </tr>"
. " </table>"
. " <p><input type=\"submit\" value=\"Submit\" name=\"B1\"><input type=\"reset\" value=\"Reset\" name=\"B2\"></p>"
. " <input type=\"hidden\" name=\"reciept\" value=\"membership@site.com\">"
. " </form></center>";
CloseTable();
include("footer.php");

?>

[edited by: jatar_k at 11:45 pm (utc) on July 3, 2003]

vincevincevince

8:45 am on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



there is no code there to send the mail - only a form for entering it

generally the function mail() is used to send - but that will need to be after the form data has been sent, the page reloaded, recieved, etc...

jatar_k

2:35 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld xtremetimes,

<form method=\"POST\">"

You need to set a form action. Do you still have the original? It may have the action that you need in there.

xtremetimes

5:25 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



This is the original i wrote it but i cant figure out how to get it to work what code to i need to add and where?
like i said i have been at this for weeks now.

lorax

5:38 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to edit this piece <form method=\"POST\"> to include the file name where this form will be sent <form action=\"somefilename.php\" method=\"POST\">

vincevincevince

6:14 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i'd put action="$PHP_SELF" as the form action.
then in your script - put a big if construct.
you'll need to fill in the rest of $message=, I'm too lazy to do it all for you!

if($_REQUEST['clan'])
{
//this guy has filled in the form
//let's send an email

$youradd = "i@love.spam";
$yourname = "Spam Monkey";
$subject = "New registration application";
$message = "The clan wanted was:".$_REQUEST['clan']." and the game-name was: ".$_REQUEST['sender_name']; //add more! one for every value in the form
$theirname = $_REQUEST['sender_name'];
$theiradd = $_REQUEST['sender_email'];
$headers =
"MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nFrom: $theirname <$theiradd>\r\nTo: $yourname <$youradd>\r\nReply-To: $theirname <$theiradd>\r\nX-Priority: 1\r\nX-MSMail-Priority: High\r\n X-Mailer: VinceVinceVince's Amazing Code";
mail($youradd, $subject, $message, $headers);
}
else
{
//this guy didn't fill the form in yet
//put in the normal form output to be filled in
//ie, the echos from your current script
}

xtremetimes

6:29 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



thanks for all your help but it is still greek to me all i have is a php form i dont have the php part that if i call it action=mail.php i dont have a script like that so basicly i will have to have this php script and create another php script for the action well i dont know alot about php I just know how to edit and add scertain things I think i am gonna give up on this and go back to my html forms the only reason i didnt want to use html forms is because i cannot place them inside php nuke.

olwen

9:36 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



Regardeless of whether you have an HTML form of a php form you still need something to process the results. Stick with the php, and learn to do the rest.

Your mail.php (or whatever you choose to call it) needs to collect the information entered and probably call the mail() function in PHP to send the message.

Look at
[php.net...]
for a description of how to do in with examples.

Keep your Nuke wrapper code so it looks nice