Quick WAMP Question

Discussion in 'Programming' started by encom, May 31, 2009.

  1. #1
    Hi, I have setup WAMP and have created a very simple form:

    
    <?php
    if (isset($_POST['submit'])) {
    
    $firstname = $_POST['firstname'];
    $surname = $_POST['surname'];
    
    if ($firstname == ''){
    print 'Enter a first name';
    }
    else{
    
    if ($surname == ''){
    print 'Enter a surname';
    }
    
    else{
    die('You filled out the form');
    }
    }
    }
    ?>
    <form action="test.php" method="post">
    First Name: <input name="firstname" type="text" value="<?php print $_POST['firstname']; ?>"><br>
    Surname: <input name="surname" type="text" value="<?php print $_POST['surname']; ?>">
    <input name="submit" type="submit" value="Submit">
    </form>
    
    Code (markup):
    I get an error message in the text boxes on wamp, but not if I uploadt the file to a webserver. Is there a setting on wamp that is wrong?

    Thanks in advance.
     
    encom, May 31, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    What error do u get ?
     
    Bohra, May 31, 2009 IP
  3. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    I get:
    <br /><b>Notice</b>: Undefined index: surname in <b>C:\wamp\www\eurogrant - PHP\test.php</b> on line <b>24</b><br />

    etc...
     
    encom, May 31, 2009 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    Well maybe php versions are diffrent not sure coz i tested the code on xampp works fine for me..
     
    Bohra, May 31, 2009 IP
  5. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Thanks Bohra,

    Could someone else test it in WAMP and maby tell me what settings I may need to change.

    Cheers.
     
    encom, May 31, 2009 IP
  6. transness

    transness Active Member

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Well, see it gives that error when you havn't submitted the form.. in that case it cant enter a default "value" in the surname field since there is nothing.
    try changing that to
    It prolly doesn't show you the error on your hosting, prolly saves it in an error_log file
     
    transness, May 31, 2009 IP
  7. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    OK cheers, I will change it tomorow and get back to you.

    Im a bit bissy now.
     
    encom, May 31, 2009 IP