skateme Posted September 3, 2007 Share Posted September 3, 2007 I'm creating a login area and stuff, so I was making this code, but when I test it, I see a blank screen.. <html><head><title>Switch Statements</title></head> <body> <?php $url="http://127.0.0.1/~me/switch.php?action="; $replacement=""; $edit="edit"; $delete="change"; $change="change"; ?> Select action: <form action="http://127.0.0.1/~me/switch.php?action=" method="post"> <input type="button" name="edit" value="Edit" onClick="<?php substr_replace($replacement,$edit,0); ?>" /><br> <input type="button" name="delete" value="Delete" /><br> <input type="button" name="change" value="Change" /><br> <?php substr_replace($url,$replacement,-1); ?> </form> <?php switch($_REQUEST[action] { case "edit"; print "Add edit function"; break; case "delete"; print "Add delete function"; break; case "change"; print "Add change function"; break; } </body></html> What's wrong with it? I thought a little bit and I thought I'd make it simpler.. <html><head><title>Switch Statements</title></head> <body> Select action: <form action="http://127.0.0.1/~me/switch.php?action=edit" method="post"> <input type="button" name="edit" value="Edit" /><br> </form> <form action="http://127.0.0.1/~me/switch.php?action=delete" method="post"> <input type="button" name="delete" value="Delete" /><br> </form> <form action="http://127.0.0.1/~me/switch.php?action=change" method="post"> <input type="button" name="change" value="Change" /><br> </form> <?php switch($_REQUEST[action] { case "edit"; print "Add edit function"; break; case "delete"; print "Add delete function"; break; case "change"; print "Add change function"; break; }; ?> </body></html> This is the script that comes up blank^ Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/67816-this-code-wont-work/ Share on other sites More sharing options...
dhimok Posted September 3, 2007 Share Posted September 3, 2007 <form action="http://127.0.0.1/~me/switch.php?action=" method="post"> the querystring action is empty. Quote Link to comment https://forums.phpfreaks.com/topic/67816-this-code-wont-work/#findComment-340829 Share on other sites More sharing options...
skateme Posted September 3, 2007 Author Share Posted September 3, 2007 please take a look at the whole code. i replaced the URL with an action at the end with substr_replace Quote Link to comment https://forums.phpfreaks.com/topic/67816-this-code-wont-work/#findComment-340832 Share on other sites More sharing options...
ishkur Posted September 3, 2007 Share Posted September 3, 2007 <html><head><title>Switch Statements</title></head> <body> Select action: <form action="http://localhost/switch.php?action=edit" method="post"> <input type="submit" name="edit" value="Edit" /><br> </form> <form action="http://localhost/switch.php?action=delete" method="post"> <input type="submit" name="delete" value="Delete" /><br> </form> <form action="http://localhost/switch.php?action=change" method="post"> <input type="submit" name="change" value="Change" /><br> </form> <?php switch($_REQUEST[action]) { case "edit"; print "Add edit function"; break; case "delete"; print "Add delete function"; break; case "change"; print "Add change function"; break; }; ?> </body></html> This worked for me. Only thing i changed was the ")" missing in the switch and puting the button type as "submit". Quote Link to comment https://forums.phpfreaks.com/topic/67816-this-code-wont-work/#findComment-340846 Share on other sites More sharing options...
darkfreaks Posted September 3, 2007 Share Posted September 3, 2007 try using $_GET['action']; Quote Link to comment https://forums.phpfreaks.com/topic/67816-this-code-wont-work/#findComment-340847 Share on other sites More sharing options...
darkfreaks Posted September 3, 2007 Share Posted September 3, 2007 ahyes i didnt notice that ??? Quote Link to comment https://forums.phpfreaks.com/topic/67816-this-code-wont-work/#findComment-340850 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.