PDA

View Full Version : Web Form



-Nick
21-04-2014, 05:08 PM
So basically i am a bit stuck ;l

I have this form in html:

This PHP file:

<form method="post" action="email.php">
First Name: <input type="text" name="firstname" /><br />
Last Name: <input type="text" name="lastname" /><br />
Email: <input type="text" name="email" /><br />
Mobile (UK): <input type="text" name="mobile" /><br />
Gender: <input type="radio" name="sex" value="male">Male<br><input type="radio" name="sex" value="female">Female Age: <input type="text" name="age" /><br />
<textarea name="message"></textarea>
<input type="submit" value="Submit">
</form>


<?php mail('[email protected]', $_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['mobile'], $_POST['sex'], $_POST['age'], $_POST['message']);?><p>Your email has been sent.</p>

But then i get this error:

Warning: mail() expects at most 5 parameters, 8 given in /home/surfhokk/public_html/apps/email.php on line 2

ideas on how i can get this not to work? or what code i need?

Chippiewill
21-04-2014, 05:11 PM
http://php.net/manual/en/function.mail.php

You need to concatenate the parameters into a single string. I would recommend filtering them first though.

-Nick
21-04-2014, 05:20 PM
http://php.net/manual/en/function.mail.php

You need to concatenate the parameters into a single string. I would recommend filtering them first though.


So would it be like this?


<?php bool mail ( string $firstname , string $lastname , string $email [, string $mobile [,string $sex ]] );?><p>Your email has been sent.</p>

Chippiewill
21-04-2014, 05:25 PM
No


<?PHP

$content = $_POST['firstname'] . $_POST['lastname'] . $_POST['email'] . $_POST['mobile'] . $_POST['sex'] . $_POST['age'] . $_POST['message'];
$content = htmlspecialchars($content);

mail ('[email protected]', "Subject name here", $content );

-Nick
21-04-2014, 05:32 PM
No


<?PHP

$content = $_POST['firstname'] . $_POST['lastname'] . $_POST['email'] . $_POST['mobile'] . $_POST['sex'] . $_POST['age'] . $_POST['message'];
$content = htmlspecialchars($content);

mail ('[email protected]', "Subject name here", $content );

Okay that works. However, when the message is sent, i look at it and its all one word.. is it possible to like new line each questions and have it set out in this format?

Subject: Application for {name here}

First Name: blah
Last Name: blah

Chippiewill
21-04-2014, 06:03 PM
<?PHP

$content = sprintf(
"First Name: %s
Last Name: %s
Email: %s
Mobile: %s
Sex: %s
Age: %s
Message: %s
", $_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['mobile'], $_POST['sex'], $_POST['age'], $_POST['message']);
$content = htmlspecialchars($content);
mail ('[email protected]', htmlspecialchars("Application for: ". $_POST['firstname'] . " " . $_POST['lastname']), $content );

-Nick
21-04-2014, 06:54 PM
How would i get all of these text boxes to align right?
http://prntscr.com/3c52oa
i tried using this code but won't align them?


<tdalign="left"></td>

Chippiewill
21-04-2014, 07:38 PM
You probably want to put style="align:right;" inside the input tags

Want to hide these adverts? Register an account for free!