Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Push a button and set a session variable

Posted on 2009-07-14
3
Medium Priority
?
742 Views
Last Modified: 2013-12-13
Yeah, so I'd like to navigate from one PHP page to another using a button. When the button is clicked I need to store some id value in the $_SESSION array to be used by the page I'm calling. How do I do this?

Below is the code for the button calling the php. I can pass the variable using GET but instead I'd like to use $_SESSION.

Thanks in advance!

      
print "<td align=\"center\"><input type=\"button\" name=\"modify_button\" value=\"Modify\" id=\"a-button\" ONCLICK=\"window.location.href='modify-ad.php\"></td>\n";

Open in new window

0
Comment
Question by:php-newbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:khyer123
ID: 24855362
here it is in php




<?php
session_start();
$_SESSION['name'] = <value>;
?>
 
<form action="destination_page.php" method="post">
<input type="submit" value="whatyouwantbuttontosay" />
</form>

Open in new window

0
 
LVL 4

Accepted Solution

by:
khyer123 earned 750 total points
ID: 24855373
Here's another solution... if you are trying to get some sort of value that a user enters in and carry it across, and you don't want to use get... then just do the below. On the next page, you can access the value via $_POST['id'], and it won't show up in the URL like get does.
<form action="destination_page.php" method="post">
<input type="text" name="id" />
<input type="submit" value="whatyouwantbuttontosay" />
</form>

Open in new window

0
 

Author Closing Comment

by:php-newbie
ID: 31603545
works for me :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question