Jump to content

sorry the real can't see anything


ball420

Recommended Posts

i'm just learning php and making ok progress. i'm testing stuff out and having a major problem..
here is my simple html code ok..

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<h1>Search for the shit</h1>
<p>&nbsp;</p>

<form action="resultsbyname.php" method="post">
  <p>enter the name of what your seeking</p>
  <p>&nbsp;</p>
  <p>
    <input name="name" type="text" />
  </p>
  <p>
    <input name="submit" type="submit" value="search" />
  </p>
</form>
<p>&nbsp; </p>
</body>
</html>

so i have that now i have my simple php code

<?

echo $name;

?>


now when i type into my form and hit submit it should show that text on the next page, well it doesn't it connects to the page but it's just blank??

i don't understand please help
Link to comment
Share on other sites

ken is absolutely right it's not anything wrong with the echo statement or the page...when you post a form to a new page the values get entered in the $_POST array for example:

If the name of the text box was "name":

[code]
$name = $_POST['name'];
echo $name;
[/code]

or

[code]
echo $_POST['name'];
[/code]
Link to comment
Share on other sites

it still not working here is my php code


<?

$name = $_POST['name'];
echo $name;

?>

here is the code from the html page


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<h1>Search for the shit</h1>
<p>&nbsp;</p>

<form action="resultsbyname.php" method="post">
  <p>enter the name of what your seeking</p>
  <p>&nbsp;</p>
  <p>
    <input name="name" type="text" />
  </p>
  <p>
    <input name="submit" type="submit" value="search" />
  </p>
</form>

</body>
</html>

what am i doing wrong??
Link to comment
Share on other sites

You should use <?php, that may be the problem anyway.

[code]<?php

$name = $_POST["name"];
echo $name;

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<h1>Search for the shit</h1>
<p>&nbsp;</p>

<form action="" method="post">
  <p>enter the name of what your seeking</p>
  <p>&nbsp;</p>
  <p>
    <input name="name" type="text" />
  </p>
  <p>
    <input name="submit" type="submit" value="search" />
  </p>
</form>

</body>
</html>[/code]
Link to comment
Share on other sites

would ther be any way to turn it on??? i'm in the learning process and it could make some things difficult in the future don't you think. if the classes im taking the guy is doing it with his settings differnent than mine???

thanks for the replies
Link to comment
Share on other sites

[quote author=ball420 link=topic=124222.msg514461#msg514461 date=1169855918]
would ther be any way to turn it on??? i'm in the learning process and it could make some things difficult in the future don't you think. if the classes im taking the guy is doing it with his settings differnent than mine???

thanks for the replies
[/quote]

Well, it's generally good practice to write your code with every scenario possible in mind. i.e, short tags or register globals being disabled. You want your code to be as compatible as possible under varrying circumstances/servers.
Link to comment
Share on other sites

Its best to get in the habit of using the longer <?php tags. This is guaranteed to work on all setups.

Also, if you don't want any errors you need to check this variable is set first. eg; Your code should look like....

[code]
<?php
  if (isset($_POST['name'])) {
    $name = $_POST['name'];
    echo $name;
  }
?>
[/code]

Its also best to get in this habit as early as possible.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.