Jump to content
xisto Community
fffanatics

$_post Without A Form Trying to post a value with using a submit button

Recommended Posts

Hey me again. Looks like im having trouble with php. THis time the solution should be easy but i just cant find it anywhere. I am trying to post a variable but i do not want to use a form because i hate the look of submit buttons for what i am using it for. I do not want to use javascript because of compatibility issues. If you know how to make a submit button look like a nomal text link that would work if you know how to send post data through an href that also would work. Or if you just know how to do it another way im open to suggestions. Thanks for all of your help

Share this post


Link to post
Share on other sites

You can easliy change the colour of the button without using Javascript, although it will still retain the button style. The code, if you are interested, is:

<INPUT TYPE="SUBMIT" VALUE="Button Text" STYLE="background:#ffff00 none; color:#0000ff">

That would create a yellow button with blue text. I could also looking into using plain text and images if you would like me to.

Share this post


Link to post
Share on other sites
<input type='image' src='image.gif' value='submit' name='submitlink'>

works too, remember to use different names for value and name, can't be the exact same

Share this post


Link to post
Share on other sites

I think you guys are mistaking what i am asking. What i want to do, if possible with css or another way, is submit a form using a text link instead of a submit button. If you can use css to make a button not look like a button but a text link instead thats cool or if you can make a text link act like a submit button thats even better. Something that works like that is what im asking for help with not the basic css properties of a button. Thanks all

Share this post


Link to post
Share on other sites

Allright, but it will take a much bigger amount of code then a normal submit button would, and it's only possible in javascript, meaning the users that dont have js support can't ever submit..

I will use an example form

<form name="example" method="post" action="yourscriptname.php">

put the following code in your <HEAD> section
<script language="JavaScript" type="text/javascript"><!--function example ( selectedtype ){  document.formname.supporttype.value = selectedtype;  document.formname.submit();}--></script>

then you can add this as your submit:
<input type="hidden" name="supporttype" /><a href="javascript:example('submit')">Submit</a>

Hope this helps you

Share this post


Link to post
Share on other sites

I may be mistaken but I think Hmmz's option is not really using a submit button. Sure it is a form element using the submit command, but that's kinda what you want to do, isn't it, submit the form. Just make a picture that looks like a text link :DAnyway I will be upping Hmmz's rep as that is exactly what I wanted to do, thanks.

Share this post


Link to post
Share on other sites

Hey thanks for the help and i was afraid that javascript was going to be the only answer. The reason is that i have a login script in php and once they login the menu on the right side of my page changes. On this menu i would like to have a text link that says logout (which i know ive seen people do) that when they click on it they would log out of my site. Anyone have other suggestions on how to do this. Also if you need the login script code let me know and ill post it.

Share this post


Link to post
Share on other sites

haha ffanatics, just use a logout text link and direct it to the logout.php

or use a page function and just logout the user on the same page, you don't need to use a form to log a user out, you could build a class in your index.php, for the logout, with an if() statement to ensure it works

use the following link to function as logout:

//make sure the user existsif($user){  echo "<a href=\"login.php?out=yes&user=$user\">Logout</a>";}
then make the function "out"

$logout = $_GET['out']; // makes sure their logging out$user = $_GET['user']; // gets the usernameif ($logout == "yes") {mysql_query("DELETE FROM active_users WHERE name='$user'"); // Logs them out}

if you don't have an "active_users" field in your user table, you should add it, it makes life easier :D

Anyway, hope this helps

Share this post


Link to post
Share on other sites

Thanks a ton for the help because that was exactly what i was looking for. I already had a class for my members and it has a logout function in it but i just didnt know how to post data in the link like you did in the <a> tag. Thanks again and ill try it out when i get home from work later and post the results.

Share this post


Link to post
Share on other sites

Thanks for the help and it works. It does wonders and you answered the actual question i was asking at the top unlike some others. Once again thanks for your help

Share this post


Link to post
Share on other sites
make a button look like text using css$_post Without A Form

for future reference, you can make a button look like text using css.

the button looks like a button, because it is given a special 'button' border and background, so the corresponding css to make it not look like a button is:

{ display: inline; border: none; background: transparent;}

of course, what you actually want it to look like is a link, so you will want to colour it right, and set cursor: pointer and so forth too...

Share this post


Link to post
Share on other sites
Without the logout.php then?$_post Without A Form

I had figured out the use of logout.Php by myself, but this I want my web site fool proof, meaning that the user should log out if, and only if he / she clicks the log out-link. My site is just like fffanatics', with a menu consisting of <a> tags and the Log out option. My problem is that if I have a page (logout.Php), a user could obviously log out from the account just by visiting that page (typing it in the address bar), which I do not want. Is there any way to fix this, still without using JavaScript? 

-reply by Sindre

Share this post


Link to post
Share on other sites
Reply to iGuest$_post Without A Form

Just add:

if (isset($_SERVER['HTTP_REFERRER'])) { die "you should not go directly to logout.Php"; }You can just spell out the message or just redirect them to the index or login page using header.

-reply by Fandi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.