|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Newbie with PHP issue
Ok, so I'm teaching myself a bit of PHP (Webmonkey) to ease the efforts of multiple static pages. I understood how to do the "transfer" of the variable input by a user into a text box, to a new PHP page and "printed" into the HTML .
I tried to take it a step further and send a coding variable to a page and have the variable be the file name for an image(thumbnails to full images). In the body of the first page I had: Code:
<form action="newPage.php" method=post>
<?php
$design="des01.png"
?>
<input type="image" src="thumb.jpg" name=submit></form>
Then in the new page: Code:
<?php
print ("<img src=\"designs/$design\">"
?>
The goal was to have the outcome as <img src="designs/des01.png"> I got the new page with out the image. The directory was there but it doesn't seem to be getting the value of the variable (<img src="designs/">). Can you tell me where I'm missing whatever it is that keeps the information from being sent/received? Maybe the form is not neccessary? Thanks (the actual code is not in front of me right now, but I'm fairly certain it's what I tried, well, one of the many variations). Any help is appreciated. -Jim |
|
#2
|
||||
|
||||
|
hi,
the $design is not assigned as a global variable, so it wont get posted from page to page, you can however create a hidden field, with the value of $design and $_Post['HiddenFieldName']; on the other page. try this Code:
page1:
<form action="newPage.php" method=post>
<?php
$design="des01.png"
?>
<input type="hidden" name="design" value="<?echo $design;?>">
<input type="image" src="thumb.jpg" name=submit>
</form>
---newPage.php
$design = $_POST['design'];
print ("<img src=""designs/".$design."">")
hope this helps
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#3
|
||||
|
||||
|
the form doesn't post data to the next page unless it is in an input field. You could do that like this:
Code:
<form action="newPage.php" method="post"> <?php $design="des01.png"; ?> <input type="hidden" name="design" value="<?=$design;?>" /> <input type="image" src="thumb.jpg" name="submit" /> </form> then on the next page: Code:
<?php
echo ("<img src=\"designs/" . $_POST["design"] . "\">";
?>
good luck!
__________________
ShepherdWeb :: Charging Rhino Wizard I know of no more encouraging fact than the unquestionable ability of man to elevate his life by conscious endeavor. {Henry David Thoreau} § shepherdweb.com § fariswheel productions § reagan administration |
|
#4
|
||||
|
||||
|
Quote:
good answer...you beat me to the punch. ![]() |
|
#5
|
||||
|
||||
|
same to you
![]() kick %ss avatar, glad to see that you can finally have one |
|
#6
|
||||
|
||||
|
Quote:
THANKS! ![]() |
|
#7
|
||||
|
||||
|
Hmmm, neither work. Maybe I need to keep reading, but hopefully I won't get hung up. Just seemed simple enough and both codes look like it makes sense. The second page just comes up blank (white screen).
![]() |
|
#8
|
||||
|
||||
|
Quote:
Do a "view source" and see what the code looks like underneath that blank white screen. |
|
#9
|
||||
|
||||
|
I did that, and there was nothing between the body tags. I did, however, get it to work. I mixed what I was doing originally, and what you suggested with the hidden input. First page code is:
Code:
<form action="/designs/des01.php" method="post"> <?php $design="des12.jpg" ?> <?php $label="Design 12" ?> <input type="hidden" name="label" value="<?=$label;?>" /> <input type="hidden" name="design" value="<?=$design;?>" /> <input name=submit type="image" src="images28/des12.jpg" width="175" height="160"> </form> and the receiving page: Code:
<?php
print $label
?>
</p>
<br><br><br><center>
<?php
print ("<img src=\"$design\">")
?>
I noticed when I tried to put set the two variables within the same PHP tags, I got the white screen. You can't just stick them all in there like other languages??? Thanks for the assistance. Can't wait to keep moving forward with this stuff! -Jim |
|
#10
|
||||
|
||||
|
Way to go! Good luck!
|
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Newbie with PHP issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|