Where are my arguments going?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uvindex
    New Member
    • Aug 2005
    • 2

    Where are my arguments going?

    Hi All: Yet another PHP newbie here with a question. :)

    I'm trying to run a script that I found on this site (the two files from the tutorial "Parsing Forms With PHP and Sending E-Mail"). The form and script work properly, for the most part (and the email function in the script does send an email). The problem I'm experiencing is that all of the variables in the PHP script seem to be empty. In other words, the values entered into the form don't seem to be making it to the PHP script (the reason I'm saying this is that the output from the script prints nothing for the occurrences of variable such as $name, $status, and $email).

    The files are reproduced; they're also hosted at http://myweb.usf.edu/~cspears/form.htm in case anyone would like to see them in action.

    Thank you in advance for any hints or pointers!
    uvindex

    This is the form file (form.htm):
    [code=html]<HTML>
    <HEAD>
    <TITLE>Form Handling with PHP</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFF F">
    <FORM METHOD=POST ACTION="tellus. php">
    <TABLE>
    <TR height="20">
    <TD colspan="2"><FO NT SIZE="-1" face="verdana"> Below is a Sample Form for our PHP tutorial </TD>
    </TR>
    <TR height="50">
    <td></td>
    </TR>
    <TR>
    <TD align="left"><F ONT SIZE="-1" face="verdana"> Your Name Your E-Mail Address</td>
    <td><INPUT TYPE="text" NAME="name">
    <br>
    <INPUT TYPE="text" NAME="email">
    </TD>
    </TR>
    <tr>
    <td colspan="2"><SE LECT NAME="opinion">
    <option value="is great">I like your site</option>
    <option value="is OK">Your Site is OK</option>
    <option value="is horrible">Your Site is horrible</option>
    </SELECT>
    <br>
    <INPUT TYPE="submit" value="Tell us!">
    </td>
    </tr>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>

    [/code]This is the script file (tellus.php):
    [code=php] <?php

    PRINT "<center><F ONT SIZE=-1 face=verdana>"; PRINT "Greetings $name, thank you for filling out our";
    PRINT "form.";
    PRINT "</center><p><cent er><TABLE border=0 width=500";
    PRINT "cellspacin g=0 cellpadding=7>" ; PRINT "<TR><TD><F ONT SIZE=-1 face=verdana>"; PRINT "In the form, you stated that our site";
    PRINT "$status. Thank you for your input."; PRINT "We will send you more information about our site";
    PRINT "in an email to $email.";
    PRINT "If you have any more comments, feel free to reply.";
    PRINT "</FONT></TD></TR></TABLE></center>";

    mail("$email", "Site Information", "Hello $name,\nWe thank
    you again for using our form and telling \nus your option
    about our site\n\nThis is important to us so we can know how
    to improve.\n\nTha nk you once again.");

    mail("cameronsp ears@yahoo.com" , "An Opinion", "$name just
    used the form.\n\nThey stated that our site $opinion.");

    ?>[/code]
  • uvindex
    New Member
    • Aug 2005
    • 2

    #2
    installation specific

    After much gnashing of teeth and finally obtaining a hosting account from a completely different organization, it seems the missing arguments problem reported above is specific to the PHP installation.

    To demonstrate: this simple script works on one server but not on another:

    [code=php]<?php

    // This page should receive a name value in the URL.

    print "<p>Hello, $name, and welcome to the web!</p>";

    ?>[/code]

    (these aren't real URLs, by the way - they're just simplified versions of verbose URLs)


    (Observed output is "Hello, JohnDoe, and welcome to the web!")


    (Observed output is "Hello, , and welcome to the web!")

    Is there a PHP installation parameter which would inhibit the passing of arguments like this?

    Thanks,
    CS

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Try using $_GET['name'] instead of $name.

      Your problem is related to the value of register_global s.

      Comment

      Working...