fert Posted December 2, 2006 Share Posted December 2, 2006 I have a PHP file that contains code like this:[code]echo "<form method=\"post\" action=\"index.php\" name=\"post\">";echo "<textarea rows=\"5\" cols=\"30\" name=\"text\"></textarea>";echo "<p><input type=\"submit\" value=\"Save\"></p></form>";[/code]But when i try to run it i get a blank page and it's not because the code has errors it. How can i fix this? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 3, 2006 Share Posted December 3, 2006 You will need to configure Apache to parse PHP files with the PHP Interpreter. What is the current state of Apache's configuration? Quote Link to comment Share on other sites More sharing options...
fert Posted December 3, 2006 Author Share Posted December 3, 2006 No apache will parse PHP files as long as they don't contain HTML forms Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 4, 2006 Share Posted December 4, 2006 Run your code again and this time go to View > SourceIs there any output, if there is post it here. Quote Link to comment Share on other sites More sharing options...
fert Posted December 4, 2006 Author Share Posted December 4, 2006 there is no output Quote Link to comment Share on other sites More sharing options...
steviewdr Posted December 5, 2006 Share Posted December 5, 2006 Try this on its own:[code]<?phpecho "<form method='post' action='index.php' name='post'>";echo "<textarea rows='5' cols='30' name='text'></textarea>";echo "<p><input type='submit' value='Save'></p></form>";?>[/code]I hope you are putting the <?php and ?> tags? Also you need to check your apache logs for errors etc.Also - try viewing the webpage with a different browser.-steve Quote Link to comment Share on other sites More sharing options...
fert Posted December 5, 2006 Author Share Posted December 5, 2006 [code]<?phpecho "<form method='post' action='index.php' name='post'>";echo "<textarea rows='5' cols='30' name='text'></textarea>";echo "<p><input type='submit' value='Save'></p></form>";?>[/code]that works[code]<?php$var=1;if($var==1){echo "<form method='post' action='index.php' name='post'>";echo "<textarea rows='5' cols='30' name='text'></textarea>";echo "<p><input type='submit' value='Save'></p></form>";}elseif($var==2){echo $var;}else{die("Error");}[/code]that works[code]<?php$var=$_GET[var];if($var==1){echo "<form method='post' action='index.php' name='post'>";echo "<textarea rows='5' cols='30' name='text'></textarea>";echo "<p><input type='submit' value='Save'></p></form>";}elseif($var==2){echo $var;}else{die("Error");}?>[/code]that doesn't work and there are no errors in the log. Quote Link to comment Share on other sites More sharing options...
steviewdr Posted December 6, 2006 Share Posted December 6, 2006 Try this and see what it echos out:[code]<?php$var=$_GET[var];echo $var;if($var==1){echo "<form method='post' action='index.php' name='post'>";echo "<textarea rows='5' cols='30' name='text'></textarea>";echo "<p><input type='submit' value='Save'></p></form>";}elseif($var==2){echo $var;}else{die("Error");}?>[/code]Debuuuuug it.-steve Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 6, 2006 Share Posted December 6, 2006 There is an error and its to do with line2:$var=$_GET[var];You should put the key in quotes if its a string. Otherwise PHP will think you're using a constant. Also if you key is also a reserved keyword and you're not putting it in quotes then you'll get an error/blank page! In your code [b]var[/b] is a reserved keyword and PHP is getting confused.So line 2 should be like this:[code=php:0]$var=$_GET['var'];[/code] Quote Link to comment Share on other sites More sharing options...
fert Posted December 6, 2006 Author Share Posted December 6, 2006 still doesn't work. Quote Link to comment Share on other sites More sharing options...
steviewdr Posted December 7, 2006 Share Posted December 7, 2006 try this (revised code by wildeen ;) )[code]<?php$test1=$_GET['var'];echo " Variable should be here: $test1";if($var==1){echo "<form method='post' action='index.php' name='post'>";echo "<textarea rows='5' cols='30' name='text'></textarea>";echo "<p><input type='submit' value='Save'></p></form>";}elseif($var==2){echo $var;}else{die("Error");}?>[/code]Also - what version of php do you have running? Do you have PHP globals switched on?-steve Quote Link to comment Share on other sites More sharing options...
remmargorp Posted December 7, 2006 Share Posted December 7, 2006 Wouldn't you want to change all $var's to $test1 in your example code?I have added test code for you to try out[code]<html><body><a href="document.php?test=10">Click Link</a><br><br><?php$sSelf = $_SERVER['PHP_SELF'];echo $sSelf . "<br>\n";$sTest = $_GET['test'];echo $sTest . "\n";?></body></html>[/code]Run the test code above, change document.php to whatever the document name is (so you can click the link to set test to equal 10).Should output this (when viewing source) when test = nothing:[code]<html><body><a href="document.php?test=10">Click Link</a><br><br>document.php<br></body></html>[/code]Should look like this (when you view source) when you click the link:[code]<html><body><a href="document.php?test=10">Click Link</a><br><br>document.php<br>10</body></html>[/code]Give the source and content of the page when you load it, then when you click the link. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.