Results 1 to 8 of 8

Thread: Web Form

  1. #1
    Join Date
    Mar 2010
    Location
    Cornwall (UK)
    Posts
    2,329
    Tokens
    6,755
    Habbo
    -Nick

    Latest Awards:

    Default Web Form

    So basically i am a bit stuck ;l

    I have this form in html:

    This PHP file:
    HTML Code:
    <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 Code:
    <?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?
    Last edited by -Nick; 21-04-2014 at 05:09 PM.


    Quote Originally Posted by xxMATTGxx View Post
    Nick is harmless and he's not a bad person after you have spoken to him a few times.
    Last +REP from: Kardan


  2. #2
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    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.
    Chippiewill.


  3. #3
    Join Date
    Mar 2010
    Location
    Cornwall (UK)
    Posts
    2,329
    Tokens
    6,755
    Habbo
    -Nick

    Latest Awards:

    Default

    Quote Originally Posted by Chippiewill View Post
    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 Code:
    <?php bool mail string $firstname string $lastname string $email [, string $mobile [,string $sex ]] );?><p>Your email has been sent.</p>


    Quote Originally Posted by xxMATTGxx View Post
    Nick is harmless and he's not a bad person after you have spoken to him a few times.
    Last +REP from: Kardan


  4. #4
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    No

    PHP Code:
    <?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 );
    Chippiewill.


  5. #5
    Join Date
    Mar 2010
    Location
    Cornwall (UK)
    Posts
    2,329
    Tokens
    6,755
    Habbo
    -Nick

    Latest Awards:

    Default

    Quote Originally Posted by Chippiewill View Post
    No

    PHP Code:
    <?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


    Quote Originally Posted by xxMATTGxx View Post
    Nick is harmless and he's not a bad person after you have spoken to him a few times.
    Last +REP from: Kardan


  6. #6
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    PHP Code:
    <?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 );
    Chippiewill.


  7. #7
    Join Date
    Mar 2010
    Location
    Cornwall (UK)
    Posts
    2,329
    Tokens
    6,755
    Habbo
    -Nick

    Latest Awards:

    Default

    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?

    HTML Code:
    <tdalign="left"></td>


    Quote Originally Posted by xxMATTGxx View Post
    Nick is harmless and he's not a bad person after you have spoken to him a few times.
    Last +REP from: Kardan


  8. #8
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    You probably want to put style="align:right;" inside the input tags
    Chippiewill.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •