Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP: Losing Form Variables

  • 02-03-2005 12:11pm
    #1
    Registered Users, Registered Users 2 Posts: 6,315 ✭✭✭


    booker.php?name=Stephen&address=info@XXXX.ie&number=085*******&Submit=Submit&tuition1=&tuition2=&tuition3=&tuition4=&tuition5=&comp_course1=Course_1_Mon_6.30pm&comp_course2=Course_1_Sat_9.30am&comp_course3=Course_1_Wed_6.30pm&comp_course4=Course_1_Wed_6.30pm&comp_course5=Course_1_Mon_6.30pm&adult_course1=&adult_course2=&adult_course3=&adult_course4=&adult_course5=

    Anything wrong with the above?

    I am passing empty fields for when people don't book courses. It never caused a problem before but has stopped working in the last week.


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    why bother passing them over then? are you doing this via form or a link?


  • Registered Users, Registered Users 2 Posts: 6,315 ✭✭✭ballooba


    Via Form.

    People have an option to book up to fifteen courses. Up to five of each variety.


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    What errors/behaviour are you getting?


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    Are you then storing the results in a database? Why do you need to pass over empty variables?


  • Registered Users, Registered Users 2 Posts: 14,149 ✭✭✭✭Lemming


    What version of PHP are you using? Later versions have global variables set to default 'off' (which is sane) so you may need to use something like the $POST[] or $GET[] system variables to extract information from the url (if I recall my php - not done anything with it in a while in all fairness). Using those variables is good practice anyway.

    What I'm thinking is that someone updated the version of php or secured it or something and that's why your variables are going walkabout.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,315 ✭✭✭ballooba


    It's putting them into a PHP page that emails them to an address and displays a thank you message with the person's name. I think Lemming might be onto something there.

    Something like this:

    <?php
    if(isset($_POST)) {
    $to = "you@you.com";
    $subject = "Form Tutorial";
    $name_field = $_POST;
    $email_field = $_POST;
    $message = $_POST;

    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

    echo "Data has been submitted to $to!";
    mail($to, $subject, $body);
    } else {
    echo "blarg!";
    }
    ?>


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Is the method in your form GET, not POST, hence why the variables appear in the URL?


  • Registered Users, Registered Users 2 Posts: 6,315 ✭✭✭ballooba


    I change it to GET for debugging.

    I forgot to change it back for testing the solution though. Was wondering why it wasn't working.


  • Registered Users, Registered Users 2 Posts: 6,315 ✭✭✭ballooba


    Thanks for the help lads.

    Lemming hit the nail on the head.

    Global variables had been turned off on the server.

    The solution was:
    $name = $_GET;
    $address = $_GET;
    $number = $_GET;
    etc.


  • Closed Accounts Posts: 146 ✭✭MrScruff


    Had this problem too recently and I was tearing my hair out for about 30 minutes, why is PHP so hard to debug??
    Answers on a postcard to the usual address...


  • Advertisement
Advertisement