SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Why does my code not work please??

    I am at my wits end here with this php scripting....
    I am just learning php to help me with my web forms, but after watching video tutorials it seems that even when I cut and paste the EXACT code as the video, mine does not work the same??
    I mean I do not change a single thing at all, but on the video their scripts work, but when I use the same script I get unpredictable results that are NOTHING like what they got....
    Most recently, I was trying to use php to process form data from an html webpage I designed, but instead of getting the results that the tutorial got, I am getting php script all over the page, and echo written out, which makes no sense to me at all.
    myform.JPG this is my webpage with the form to enter data.
    myresults.JPG this is what comes out from the php file that is supposed to process the form data.
    PHP Code:
    <?php
    $var1 
    $_GET['name'];
    $var2 $_POST['phone'];
    $var3 $_POST['email'];
    echo 
    "Telephone number is " $var2 "<br />;
    echo "
    Email address is " . $var3 . "<br />;
    echo 
    "Full name is " $var1 "<br />;
    ?>
    this is my php script
    I cannot understand why echo is being shown on the webpage at all, nor why it is ignoring the full name variable??
    Can someone PLEASE explain what is happening here??
    Attached Images Attached Images

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,603
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Code:
    <?php
    $var1 = $_GET['name'];
    $var2 = $_POST['phone'];
    $var3 = $_POST['email'];
    echo "Telephone number is " . $var2 . "<br>";
    echo "Email address is " . $var3 . "<br>";
    echo "Full name is " . $var1 . "<br>";
    ?>
    You forgot to close your strings with a double quote.

    In your submission form, are you using a POST method or a GET method? For the most part, you don't mix the two.

    Lastly, what tutorial are you using? If you copied and pasted directly, it might be full of mistakes.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Quote Originally Posted by Force Flow View Post
    Code:
    <?php
    $var1 = $_GET['name'];
    $var2 = $_POST['phone'];
    $var3 = $_POST['email'];
    echo "Telephone number is " . $var2 . "<br>";
    echo "Email address is " . $var3 . "<br>";
    echo "Full name is " . $var1 . "<br>";
    ?>
    You forgot to close your strings with a double quote.

    In your submission form, are you using a POST method or a GET method? For the most part, you don't mix the two.

    Lastly, what tutorial are you using? If you copied and pasted directly, it might be full of mistakes.
    Thanks for the reply, but I got it to work last night, hangin: and on the video that I got the code snippet from it worked just fine as I posted it.... It was a video, so I got to watch it run, and work, :
    Still, thanks for taking the time yo!!


Tags for this Thread

Bookmarks

Posting Permissions

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