I'm working on a tutorial that involves database transactions. In order to set up a form I plan on using within the latter parts of the tutorial, I thought that POST'ing to PHP_SELF to return the values of the form inputs would help me along the way with seeing how things process. While I'm now unsure as to the virtue of this, I'm now wanting to understand what is going wrong with it regardless. So to that end, below is the code I'm currently working with:
Code: Select all
<body>
<form action="<?php echo basename($_SERVER['PHP_SELF']);?>" method="POST">
<label>Store a joke of your own: <input type="text" value="" name="vis_joke" /></label><br />
<input type="submit" value="Submit" name="submit" />
</form>
<?php
//Grab user input and store into variables...
if(!isset($_POST['vis_joke'])){
$vis_joke = 'This form has not been used yet.';//not set (form has not been used yet)...
}elseif($_POST['vis_joke'] = ''){
$vis_joke = 'The submitted value was spaces. Unacceptable!';//form used but blank space submitted...
}else{
$vis_joke = mysql_real_escape_string($_POST['vis_joke']);//good?...
}
echo $vis_joke;
?>
</body>
Ignoring the obvious security holes and non-standards compliant code (some of this was done in a hurry), I'm curious as to why the values here within $vis_joke are not being displayed at the end when I press "submit." They WERE being displayed after each submit, however, I recently tried to make the second condition value of $vis_joke display if and when it's set value was nothing more than blank spaces (which, to me, was different than just "being set" [first condition]). The last condition, of course, is the one where the value of $vis_joke is appropriate and "normal."
I know I'm way off on this, but if anyone could shine some light here, I would really appreciate it. I think I'm over-thinking things...
