Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post PHP Program Some Error

    <html>
    <head>
    <title>Personal INFO</title>
    </head>
    <body>

    <form method="post" action="<?php echo $PHP_SELF;?>">
    FORM:<BR/>
    First Name:<input type="text" size="12" maxlength="12" name="Fname"><br />
    Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
    <strong>Gender:</strong><br />
    Male:<input type="radio" value="Male" name="gender"><br />
    Female:<input type="radio" value="Female" name="gender"><br />
    <strong>Please choose type of residence:</strong><br />
    Steak:<input type="checkbox" value="Steak" name="food[]"><br />
    Pizza:<input type="checkbox" value="Pizza" name="food[]"><br />
    Chicken:<input type="checkbox" value="Chicken" name="food[]"><br />
    <textarea rows="5" cols="20" name="quote" wrap="physical">Enter your favorite quote!</textarea><br />
    <STRONG>Select a Level of Education:</strong><br />
    <select name="education">
    <option value="Jr.High">Jr.High</option>
    <option value="HighSchool">HighSchool</option>
    <option value="College">College</option></select><br />
    <strong>Select your favorite time of day:</strong><br />
    <select name="TofD" size="3">
    <option value="Morning">Morning</option>
    <option value="Day">Day</option>
    <option value="Night">Night</option></select><br />
    <input type="submit" value="submit" name="submit">
    </form>
    <?php
    $Fname = $_POST["Fname"];
    $Lname = $_POST["Lname"];
    $gender = $_POST["gender"];
    $food = $_POST["food"];
    $quote = $_POST["quote"];
    $education = $_POST["education"];
    $TofD = $_POST["TofD"];
    if (!isset($_POST['submit']))
    {
    }
    else
    {
    echo "Hello, ".$Fname." ".$Lname.".<br />";
    echo "You are ".$gender.", and you like ";
    foreach ($food as $f) {
    echo $f."<br />";
    }
    echo "<i>".$quote."</i><br />";
    echo "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";
    }
    ?>
    </body>
    </html>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Is this a question?
    You'll have up to 8 errors in this script on a non-post run. This line will always trigger: <form method="post" action="<?php echo $PHP_SELF;?>"> as there is no variable $PHP_SELF unless you have register_globals enabled. These have been disabled by default since 4.2, and removed as of 5.4.
    Every one of these will throw an error guaranteed on non-post of the script:
    PHP Code:
    $Fname $_POST["Fname"];
    $Lname $_POST["Lname"];
    $gender $_POST["gender"];
    $food $_POST["food"];
    $quote $_POST["quote"];
    $education $_POST["education"];
    $TofD $_POST["TofD"]; 
    You cannot extract from an offset that doesn't exist. Make sure each exists first, and then proceed.
    PHP Code:
    if (isset($_POST['Fname'], $_POST['Lname'], $_POST['gender'], ...))
    {
        
    // processing instructions here.

    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Tags for this Thread

    Posting Permissions

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