/    Sign up×
Community /Pin to ProfileBookmark

php variable problem…..

hey i made a script while i was learning php but i have no clue to why its working.

[code=php]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<title>Joe’s Request for a PHP Posting Script, granted! Post? Script Made by moi.</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>

<body>
<?php
$post = $_POST[‘post’]
?>
<center>
<h1>Your Post</h1>
<p>&nbsp;</p>
<fieldset>
<legend>Submited By <?php echo $name ?></legend>
<pre>
<font size=”-1″> Post #<?php echo $postnum ?></font>
<br><?php print $post ?>
</pre>
</fieldset>
</center>
<p>&nbsp;</p>
<br>
<center>
<hr width=”80%”>
<p>&nbsp;</p>
<pre>
Copyright&copy Richard Wilson 2005, All Rights Reserved.

Visit our <a href=”www.365th.aarecon.com”>Site here….</a>
</pre>
</center>
</body>
</html>
[/code]

i only allowed the $post variable but the name and post num variables work great…… how are they working when i didnt specify them the html part goes like this….

[code=html]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<title>Joe’s Request for a PHP Posting Script, granted! Post? Script Made by moi.</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>

<body>
<center>
<h1>Posting System</h1>
<h2>Made for Joe….</h2>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form action=”post.php” method=”post”>

<table border=”0″>
<tr>
<td width=”325″>Please enter your post…..<br></td>
<td width=”151″>please enter a number between 1-100 (post #)</td>
</tr>
<tr>
<td align=”center”><br>
<textarea name=”post” cols=”50″ rows=”5″ id=”post”>Type your post here….</textarea>
</td>
<td align=”center”>
<input name=”post2″ size=”8″ maxlength=”2″>
</td>
</tr>
<tr>
<td colspan=”2″ align=”center”><input name=”name” type=”text” value=”Enter Name Here…”></td>
</tr>
<tr>
<td colspan=”2″ align=”center”>
<br><hr width=”80%”><br><input name=”Submit” type=”submit” value=”Submit Da Post!”>
</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<br>
<hr width=”80%”>
<p>&nbsp;</p>
<pre>
Copyright&copy Richard Wilson 2005, All Rights Reserved.

Visit our <a href=”www.365th.aarecon.com”>Site here….</a>
</pre>
</center>
</body>
</html>
[/code]

please help!!!!

the script can be found [URL=http://365th.aarecon.com/phppassword/phptests/post.htm]here![/URL]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MarkLMay 20.2005 — When you submit your form, any form element that is set as <input name = ""> will be passed to the php script that you set with the <form action = ""> element. So, in this line:

[code=php]<td colspan="2" align="center"><input name="name" type="text" value="Enter Name Here..."></td>[/code]

You are actually sending the variable "name" to post.php and it is received as the variable $name with the value of whatever is entered by the user into that field.
Copy linkTweet thisAlerts:
@ownedmanauthorMay 20.2005 — thanx
Copy linkTweet thisAlerts:
@NogDogMay 20.2005 — Note that it depends on your PHP configuration. If [url=http://www.php.net/manual/en/ini.core.php#ini.register-globals]register_globals[/url] is off (which is the default from PHP 4.2.0 on), then the post/get values can only be refered to via the $_POST or $_GET arrays, thus it is best to always refer to them this way to increase script portability.
[code=php]
# use this way:
echo $_POST['name'];

# instead of this way:
echo $name;

# or, if you use it a lot and want to type less, do this first:
$name = $_POST['name'];
[/code]
×

Success!

Help @ownedman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...