Jump to content

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
https://forums.phpfreaks.com/topic/149140-solved-make-a-button-use-a-script/
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.

<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'"/>

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??

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

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>

 

 

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

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.