Hi, i'm new to the IF statement and I can't find help anywhere. I've tried posting in here for some help but I can't seem to post in the right category. I would like to use the IF statement to only show generated code when a user clicks submit. The form I use is <form action="#"> so it reloads in the same page but at present the code is already there, so after doing some research I found out that I need to implement the IF statement. Please somebody help me? Scott.
Thought so! I have better knowledge of php then the rest but javascript or php would work better I think. I hope you all understand what I mean because I don't think I explained it properly. Take a look at: http://www.myspace4yourpage.com/Generators/whore-me.html You see the way the code is already there? I want to have it so the code only displays when there is actually code to generate. The pages are all in php but I use a rewrite rule to change them. I really hope someone can help because it's been bugging me for a while. Thanks guys!
Change your form to: <form action="<?=$_SERVER["php_self"]?>" method="post"> <?php if($_POST['name']!='') { $code = '<table border="0" class="content" align="center" width="70%" style="border:2px solid black"><tr> </tr> <tr> <td bgcolor="beige" align="center"> <table border="0" class="content"> <td><a href="http://www.myspace4yourpage.com/add_"><img src="" height="100" width="150"></a></td><tr> <td>Name:<font color="beige">'.$_POST['name'].'</font></td><tr> <font size="5"></font> </table> <table> <td><a href="http://www.myspace4yourpage.com/add_"><img src="http://www.myspace4yourpage.com/images/addicon.gif" border="0"></a></td><td><a href="http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID="> <img src="http://www.myspace4yourpage.com/images/messageicon.gif" border="0"></a></td> </table> <br><br><br> <a href="http://www.myspace4yourpage.com/add_39723601">Add This Too!</a> <br><br> </form><br><a href="http://www.myspace4yourpage.com">Myspace Content</a></center></form></style> </table></table> ';//etc etc } ?> PHP: <textarea><?=$code;?></textarea> It's a spartan code but I hope you get the idea...
Hi, thanks a lot for the help... Still having a slight glitch. Here is how I have laid the code out: <form action="<?=$_SERVER["php_self"]?>" method="post"> <?php if($_POST['name']!='') { $code = '<table border="0" class="content" align="center" width="70%" style="border:2px solid black"><tr> </tr> <tr> <td bgcolor="beige" align="center"> <table border="0" class="content"> <td><a href="http://www.myspace4yourpage.com/add_"><img src="" height="100" width="150"></a></td><tr> <td>Name:<font color="beige">'.$_POST['name'].'</font></td><tr> <font size="5"></font> </table> <table> <td><a href="http://www.myspace4yourpage.com/add_"><img src="http://www.myspace4yourpage.com/images/addicon.gif" border="0"></a></td><td><a href="http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID="> <img src="http://www.myspace4yourpage.com/images/messageicon.gif" border="0"></a></td> </table> <br><br><br> <a href="http://www.myspace4yourpage.com/add_39723601">Add This Too!</a> <br><br> </form><br><a href="http://www.myspace4yourpage.com">Myspace Content</a></center></form></style> </table></table> ';//etc etc } ?> <table border="0" class="content" align="center" width="70%" style="border:2px solid black"><tr> <td bgcolor="3399FF" align="center"><b>The Work Area</b></td> </tr> <tr> <td bgcolor="beige" align="center"> <table border="0" class="content"> <tr><td>Your Name:<br> <input type="text" name="name" class="form"></td> <td> Text:<br> <input type="text" name="subtext" class="form" value="Add Me!"></td></tr> <tr><td> Picture URL:<br> <input type="text" name="pictureurl" class="form"></td> <td>FriendID:<br> <input type="text" name="friendid" class="form"></td></tr> <tr><td> <br /><input type="submit" value="Generate" class="form"><br /><br /><br><br><tr><tr> <table border="0" class="content" align="center" width="50%" style="border:2px solid black"><tr> <td bgcolor="#3399FF" align="center" style="border:1px solid lightblue"><b>Your Code</b></td> </tr> <tr> <td bgcolor="beige" align="center"> <table border="0" class="content"><tr> <td> <center><textarea><?=$code;?></textarea></table></table> Code (markup): If you have a look: http://www.myspace4yourpage.com/Generators/whore-me.html The generated code doesn't change from: <?php if($_POST['name']!='') { $code = '<table border="0" class="content" align="center" width="70%" style="border:2px solid black"><tr> </tr> <tr> <td bgcolor="beige" align="center"> <table border="0" class="content"> <td><a href="http://www.myspace4yourpage.com/add_"><img src="" height="100" width="150"></a></td><tr> <td>Name:<font color="beige">'.$_POST['name'].'</font></td><tr> <font size="5"></font> </table> <table> <td><a href="http://www.myspace4yourpage.com/add_"><img src="http://www.myspace4yourpage.com/images/addicon.gif" border="0"></a></td><td><a href="http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID="> <img src="http://www.myspace4yourpage.com/images/messageicon.gif" border="0"></a></td> </table> <br><br><br> <a href="http://www.myspace4yourpage.com/add_39723601">Add This Too!</a> <br><br> </form><br><a href="http://www.myspace4yourpage.com">Myspace Content</a></center></form></style> </table></table> ';//etc etc } ?> Code (markup): Thanks, Scott.
On my site (on the weblog), I made a setting that if trun=1, to trim the blog at 5 posts. Then I used GET to have PHP look at the URL and decide what to do.
NinjaNoodles, that sounds good! All i wanted it to do was just display the html code after a user clicks generate. The code that Manilodason gave me worked just enough for me to work out what to do. Take a look here: http://myspace4yourpage.com/Generators/whore-me.html Then take a look: http://myspace4yourpage.com/Generators/makebg.html I just didn't want any users getting confused thinking the code is already there when it isn't. It works fine now and i'm about to add the if statement to all my generators. Thanks again everyone this was an issue that fiddled me for ages. I love learning!