Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

$_post Without A Form


15 replies to this topic

#1 fffanatics

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 936 posts
  • Location:West Chester, PA

Posted 03 June 2005 - 06:11 PM

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

#2 rvalkass

    apt-get moo

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3,107 posts
  • Gender:Male
  • Location:Devon, England
  • Interests:At the moment, Physics mainly!
  • myCENT:21.63
  • Spam Patrol

Posted 03 June 2005 - 06:34 PM

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.

#3 HmmZ

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 362 posts
  • Location:The Netherlands

Posted 03 June 2005 - 07:55 PM

<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

#4 fffanatics

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 936 posts
  • Location:West Chester, PA

Posted 04 June 2005 - 04:12 AM

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

#5 HmmZ

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 362 posts
  • Location:The Netherlands

Posted 04 June 2005 - 08:00 AM

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

#6 moldboy

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 516 posts
  • Location:Canada Eh?!?

Posted 05 June 2005 - 04:05 AM

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 :D

Anyway I will be upping Hmmz's rep as that is exactly what I wanted to do, thanks.

#7 fffanatics

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 936 posts
  • Location:West Chester, PA

Posted 05 June 2005 - 04:30 AM

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.

#8 HmmZ

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 362 posts
  • Location:The Netherlands

Posted 05 June 2005 - 06:15 AM

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 exists
if($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 username
if ($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

#9 fffanatics

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 936 posts
  • Location:West Chester, PA

Posted 05 June 2005 - 04:02 PM

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.

#10 fffanatics

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 936 posts
  • Location:West Chester, PA

Posted 08 June 2005 - 03:20 AM

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

#11 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 01 May 2009 - 03:23 PM

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



#12 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 31 July 2009 - 01:13 AM

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

#13 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 12 November 2009 - 05:56 AM

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

#14 phatuis

    Newbie [Level 2]

  • Kontributors
  • PipPip
  • 36 posts

Posted 16 November 2009 - 05:31 AM

sing $_GET instead of $_POST would be your best option, unless you are sending over characters for at least 1 $_GET, then you might have a bit of trouble using $_POST

#15 contactskn

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 756 posts

Posted 16 November 2009 - 11:47 AM

Dear friends really helpfull topic. Even I was searching a method as such. Basically somewhat related to this topic only. So thank you all very much for such a fruitfull discussion. Thanks again. 

#16 rubikcode

    Newbie [Level 2]

  • Kontributors
  • PipPip
  • 27 posts
  • Gender:Male
  • Location:Singapore
  • myCENT:42.77

Posted 07 December 2009 - 03:04 AM

What exactly are you using this for? because if you are using it for a login/logout/registration script it would cause a lot of security issues with the password being sent around in URLs.

It would be safer to use Javascript and work around a solution. Better still just bear with a submit button. Get is just too insecure.

Anyway, thats just my opinion.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users