Jump to content

[SOLVED] Make a button use a script


ashrobbins87

Recommended Posts

How do I make a button carry out the functionality from a separate php file? I wanting to make a logout button, and the script is...

 

<?php

setcookie("auth");

header("Location:home.php");

exit;

?>

 

and the code I've tried to use to make the button carry out the functionality is...

 

<input type="button" name="Logout" value="Logout" onClick="cmslogout.php">

 

No joy.

Link to comment
Share on other sites

actually you just make a link to a script that logs you off

well actually not if he wants a button, which he stated in his original script...

true. But in the big picture what should matter more is what it does and not what tag it uses. Using a link instead of a <input /> or <button /> tag makes it possible to log out without javascript. You wouldn't want someone to turn on javascript just so they can log out.

Link to comment
Share on other sites

<a href="logout.php"><img src="button.jpg" border="0"  /></a>

 

OR

 

<a href="javascript: window.location.href='logout.php' ;" ><img src="button.jpg" border="0" /></a>

 

OR

 

<input type="button"  value="Log Out" onclick="window.location.href='logout.php'"/>

Link to comment
Share on other sites

Thank you everyone for all your help, at the moment the code I've got is...

 

<a href="logoutcms.php"><input type="button" name="Logout" value="Logout"></a>

 

...but for some reason this wont work in IE. I have tested in Firefox and Chrome and its fine but is there any reason why IE wouldn't like it??

Link to comment
Share on other sites

I've tried all of these solutions, and they dont seem to work in any browser, not just IE! ???

 

The <input...> tag is enclosed within <form> tags, I also tried using the ...

 

<form action="logoutcms.php" method="GET">

 

...that was suggested but no joy...

Link to comment
Share on other sites

I've tried all of these solutions, and they dont seem to work in any browser, not just IE! ???

 

The <input...> tag is enclosed within <form> tags, I also tried using the ...

 

<form action="logoutcms.php" method="GET">

 

...that was suggested but no joy...

 

try by using this

<form action=logoutcms.php method=GET>
   <input type=submit name=logout value=logout />
</form>

 

 

Link to comment
Share on other sites

<form action=logoutcms.php method=GET>
   <input type=submit name=logout value=logout />
</form>

 

Your markup is invalid. You're mixing HTML and XHTML syntax. You need to either enclose attribute values in single or double quotes, or you need to remove the self closing part of the input tag.

Link to comment
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.