Hello,
needing some basic php help (or at least I think its basic) , as I am new and feel I must just not be doing this correctly.
Basically, I have a form , with just two fields , as seen at http://casesshadow.com/test/tester.php (feel free to test), using a standard code :
<form method="POST" action="http://casesshadow.com/test/tester2.php" target="_blank">
<input type="text" name="h1" size="30"><BR>
<input type="text" name="h2" size="30">
<p><input type="submit" name="submit" value="Submit">
</form>
On the tester2.php I have the following code :
<?php
$h1 = "APPLE ". Trim(stripslashes($_POST['h1']));
$h2 = "APPLE ". Trim(stripslashes($_POST['h2']));
print "
<B>$h1</b><bR>
<b>$h2</b>
";
So that it returns the code with the word APPLE in front of the value, which works fine.
The issue I am having is if I fill in the form, and I only have one value you to input, Then I want the result page just to show show:
APPLE - H1 Value
But instead it prints:
APPLE - H1 Value
APPLE
So I just need it not print out the blank fields.
So I thought it would work if I used the empty value :
Created a new test page
casesshadow.com/test/test.php with the html code, and the post page coding looks like this :
<?php
if (!empty($h1)) {
$h1 = "APPLE ". Trim(stripslashes($_POST['h1']));
}
if (!empty($h2)) {
$h2 = "APPLE ". Trim(stripslashes($_POST['h2']));
}
print "
<B>$H1</B><BR>
<b>$h2</b>
";
Thought that would work, but now its not returning any thing on the next page, as if its counting everything as blank .
I also tried to use something like
if(isset($_POST['h11'])){
$h11 = "<font color=#0000ff><font size=3>". Trim(stripslashes($_POST['h1']));
}
but it didnt have any effect.
Seems like it must be something simple that i am missing. If anyone can help me do the correct code for this I would appreciate it
Thanks