Gossamer Forum
Quote Reply
PHP mail()
This may sound like a stupid question to most of you but I am learning web developing and need help with php forms.

I have created the form. I have created the script and it seems to work i.e. it picks up and displays the fullname variable which is an input field. It also displays the thank you msg in its entirety.

However, I have no idea where it's saving the input collected the form. It's certainly not mailing it to me. I tried to take a look at the mail () but got all confused.

Also, do I need to save all my php scripts in a cgi folder?

Could someone please help me? Unimpressed Thanks.

Here is my PHP script. My form has 3 fields $fullname, $email, $comments



<?php
/*Isset function, L1 to L12, checks to ensure user was directed from
the feedback If not then it sends them back to fill the form. You MUST
have the "exit" break for security reasons it prevents users to
view codes below the "exit;" */

if(!isset($HTTP_POST_VARS["feed"]))
{
header("Location: feedback.htm");
exit;
}

?>

<html>
<head><title>Contact Form</title></head>

<body bgcolor="#FFFFFF" text="#333333" link="#000000">


<table border="0" cellpadding="0" cellspacing="0" width="100%"
bgcolor="#E5E5E5">
<tr>
<td><p align="left" class="heading1"><font size="2"
face="Verdana"><img
src="../practise/sahara.jpg"
align="left" hspace="6" width="115" height="151"></font><font
size="5" face="Verdana"><b>Thank You </b><b><i><?php echo "$fullname!" ?></i></b><b>
</b></font></p>
<blockquote>
<p align="left"><font size="2" face="Verdana"><br>
You will hear from us ONLY IF we have an answer to
your question. In the meantime, please visit us at the
fanclub. <br>
<br>
</font><a
href="http://groups.yahoo.com/"
target="new"><font size="2" face="Arial"><strong>Click
here</strong></font></a><font size="2" face="Arial">
to join or visit the club.</font><font size="5"
face="Verdana"> </font></p>
</blockquote>
</td>
</tr>
</table>
</div>
</body>
</html>
Quote Reply
Re: [chokri] PHP mail() In reply to
Erm, why make it so hard for yourself? Have the form and submission stuff in one form... try this;

Code:
<?php

// first of all, see if $action is defined...
if ($action) { do_send(); exit; }

// if we get this far, then we can show the HTML form...

?>

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
</head>

<body>

<form method="POST">
<p><font face="Tahoma"><font size="2">Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font><input type="text" name="name" size="20"></font></p>
<p><font face="Tahoma"><font size="2">Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font><input type="text" name="email" size="20"></font></p>
<p><font face="Tahoma"><font size="2">Comment: </font>
<textarea rows="2" name="contact" cols="20"></textarea></font></p>
<p align="center"><font face="Tahoma">
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></font></p>
<input type="hidden" name="action" value="do_send">
</form>

</body>

</html>

<?php
//start again, so we can define the other sending sub...

function do_send {

$subject = "my subject here";
$webmaster = "webmaster@yoursite.com";

mail("$webmaster", $subject, $contact,
"From: $email\r\n"
."Reply-To: $email\r\n");

echo "message was sent";

}

?>

That should do what you want Wink

Oh, and you DON'T want to put the PHP scripts in your cgi-bin, as this will most likely cause it to produce a 500 Internal Server Error Crazy

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Nov 29, 2002, 2:57 AM
Quote Reply
Re: [Andy] PHP mail() In reply to
Andy thank you so much for replying. I will try your code now and will let you know if it works. A question for you. I have seen a lot of posts from you here at the forum. Are you with Gossammer or just a regular at this forum.

I am asking because I was wondering how often I can ask you questions.

Thanks ... off to try the code now.

THANK YOU!!
Quote Reply
Re: [chokri] PHP mail() In reply to
All staff have "staff" under their usernames :)
Quote Reply
Re: [chokri] PHP mail() In reply to
Nope, I'm not with Gossamer, but I like their forum, with the friendly feel, and also love their products Smile

If you have any more questions, feel free to ask. Me, or Dan (another regular PHP user), or anyone who knows PHP will try and help you :-)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!