Jul 25, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

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

fffanatics
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

Reply

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

CODE

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

Reply

HmmZ
CODE
<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

Reply

fffanatics
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

Reply

HmmZ
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
CODE
<form name="example" method="post" action="yourscriptname.php">


put the following code in your <HEAD> section
CODE
<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:
CODE

<input type="hidden" name="supporttype" />
<a href="javascript:example('submit')">Submit</a>


Hope this helps you

 

 

 


Reply

moldboy
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 tongue.gif

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

Reply

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

Reply

HmmZ
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:
CODE

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

then make the function "out"

CODE
$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 wink.gif

Anyway, hope this helps

Reply

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

Reply

fffanatics
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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php post without form - 4.43 hr back. (1)
  2. html php post a value - 6.79 hr back. (1)
  3. retain form values on refresh php - 8.51 hr back. (1)
  4. javascript submit/post from one html to another - 9.31 hr back. (1)
  5. "$_post" - 9.57 hr back. (1)
  6. submitting post data without using button - 10.73 hr back. (1)
  7. send post data without a form php - 14.49 hr back. (1)
  8. php $_post using buttons - 26.29 hr back. (1)
  9. php post data without a form - 27.72 hr back. (1)
  10. html put _post in href link - 35.43 hr back. (1)
  11. php html form using a link instead of submit button - 61.68 hr back. (1)
  12. create $_post array without form - 62.24 hr back. (1)
  13. send post query without form php - 71.61 hr back. (1)
  14. using $_post with - 71.94 hr back. (1)
Similar Topics

Keywords : submit button

  1. Getting Information From Submit Button - I need to grab information from a submit button. (1)
    I basically have an array that uses characters as keys and has an integer value to it. I have a
    loop that outputs the list in that array. For each entry I want a a button to remove it. The button
    will submit the form to another page which contains the script to be able to remove it from the
    array. The infomation for the keys name is used for the buttons name value. Im not sure how you go
    about grabbing this information once on the submitted page. heres my code CODE
    echo("<form name='jobs' action='remove_job.php'>"); foreach...
  2. Stop Double Post/submit - (10)
  3. Form Dosn't Submit In Opera - Works in IE and FireFox (1)
    My form dosn't submit, it works in IE and FF, its validated HTML 4.01 and all, Code:
    /**********************************/ /** Post Topic :: EvilBoard **/
    /**********************************/ /* Session Start */ session_start(); /* Start Submit Script */
    if ( isset($_POST )) { header("Refresh: 0; redirect.php?posttopic");
    define("RELOADED","YES"); } /* End Submit Script */ /* Include File::Header.php */
    include("include/header.php"); echo " "; /* If Script can't find SESSION user_name */ if (
    !$_SESSION ) { /* Echo :: Forbiden */ echo '...
  4. Submit Restrictions - Is there anyway to bypass this on my localhost? (21)
    This can be considered my first php page after a long while, I did a little basic php years ago and
    I have totally forgotten most of it. But I have come up with a page; a simple calculator if you will
    with the essential add, subtract, multiply and divide functions. When I load the page on my
    localhost, I get this error However when I upload it to trap17, there is no problem, please
    take a look http://darran.trap17.com/php/Calculator/calculator.php I know this does not matter
    but I want to find out where I went wrong on my first php page. The code listing for ...
  5. Request: Php Submit Script With Save In Host - Get Picture form url (13)
    Hi all i want make one form whit php , when users submit there urls , then my site give one picture
    form url and save on my host ! how can do that ? thanks...



Looking for post, form, post, submit, button

Searching Video's for post, form, post, submit, button
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE