Jump to content

this code won't work!


skateme

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/67816-this-code-wont-work/
Share on other sites

<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".

Link to comment
https://forums.phpfreaks.com/topic/67816-this-code-wont-work/#findComment-340846
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.