Problems Coding A Php Form

Discussion in 'Gaming' started by .vivid, Jul 28, 2008.

  1. .vivid

    .vivid Senior Member

    Age:
    32
    Posts:
    1,038
    Likes Received:
    0
    Joined:
    Apr 14, 2005
    Ok well currently I'm working on a website for a club at my high school. I need to have an area where people are able to signup for the club online.

    I have the forum created which is as follows:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><form method="post" action="process.php">
    <table width="400" border="0" cellpadding="5">
    <tr>
    <td>Name (First and Last):</td>
    <td><input type="text" size="20" maxlength="40" name="name" /></td>
    </tr>
    <tr>
    <td>Email Address:</td>
    <td><input type="text" size="20" maxlength="40" name="email" /></td>
    </tr>
    <tr>
    <td>Phone Number:</td>
    <td><input type="text" size="20" maxlength="40" name="phone" /></td>
    </tr>
    <tr>
    <td>Homeroom:</td>
    <td><input type="text" size="5" maxlength="6" name="hr" /></td>
    </tr>
    <tr>
    <td>Grade:</td>
    <td>
    <select name="grade">
    <option>9th Grade</option>
    <option>10th Grade</option>
    <option>11th Grade</option>
    <option>12th Grade</option>
    </select>
    </td>
    </tr>
    <tr>
    <td width="40" valign="top" nowrap="nowrap">Other questions, comments or concerns:</td>
    <td><textarea cols="40" rows="5" id="other"></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input name="submit" type="submit" id="submit" value="Submit" /></td>
    </tr>
    </table>
    </form></div>

    Then I have the PHP page written but the problem is that when I click submit the form goes to a blank page and I do not receive the email that I am trying to generate with the PHP script. Also my ideal method for collecting all the signups is that I can log into an area and just see everything and print it rather than having it all sent to an email inbox. If anyone can help me with this please let me know.

    PHP Form:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php

    //User output
    echo "

    Thank you, $_POST[name}, for signing up with the FBLA!</p>";
    echo "

    Don't forget to bring the club fee to your next meeting or L03.</p>";

    //Mail string
    $msg = "Name: $_POST[name]\n";
    $msg .= "Email: $_POST\n";
    $msg .= "Phone Number: $_POST[phone]\n";
    $msg .= "Homeroom: $_POST[hr]\n";
    $msg .= "Grade: $_POST[grade]\n";
    $msg .= "Other: $_POST[other]\n";

    //Mailing Info
    $recipient = "[email protected]";
    $subject = "Signup for $_POST[name]";

    //Send the mail
    mail($recipient, $subject, $msg);

    ?></div>
     
  2. r3m1x

    r3m1x Well-Known Member

    Posts:
    2,260
    Likes Received:
    0
    Joined:
    Jun 21, 2005
    Location:
    New York City
    I'm not exactly a ----- at PHP but shouldn't it be:

    Code:
    $msg = "Name:" .  $_POST["name"];
    or

    Code:
    $msg = "Name:  {$_POST['name']} ";
    I remember that you have to use braces somewhere...not really sure where. Try echoing $msg after one of these.

    oh and you have this thing happening
    echo "

    Thank you, $_POST[name}
     
  3. .vivid

    .vivid Senior Member

    Age:
    32
    Posts:
    1,038
    Likes Received:
    0
    Joined:
    Apr 14, 2005
    Wow that was such a simple fix but it did the trick. All it was was that one bracket. =] Thanks again.
     

Share This Page