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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.