[PHP-DB] Passing variables to a PHP script on clicking a hyperlink
Hello, How can I pass variables on clicking a hyperlink to a PHP script? I have 5 hyperlinks, all pointing to the same PHP script. However, on clicking each hyperlink a different value of the variable needs to be passed to the PHP script. i.e. I have 5 databases from which I want to obtain information, however the information should be displayed only when the user clicks on the hyperlink for that database. How can I pass the database name to the PHP script? How would the script know which database to get information from? I am new to PHP so any help would be greatly appreciated. I hope my question is clear. Thanks, Suamya. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
On 8/23/07, Suamya Srivastava [EMAIL PROTECTED] wrote: Hello, How can I pass variables on clicking a hyperlink to a PHP script? I have 5 hyperlinks, all pointing to the same PHP script. However, on clicking each hyperlink a different value of the variable needs to be passed to the PHP script. i.e. I have 5 databases from which I want to obtain information, however the information should be displayed only when the user clicks on the hyperlink for that database. How can I pass the database name to the PHP script? How would the script know which database to get information from? I am new to PHP so any help would be greatly appreciated. I hope my question is clear. use GET foo.php?param=value or you could use POST by using some client-side javascript to do a form submit with key/value pairs. this is a *very* simple operation... all web-enabled languages understand HTTP POST/GET/etc. - those are the main ways of exchanging data between client/server. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
I think that you can also do that buy making a drop down list with the available databases and pass the chosen database to another (or perhaps the same) script and make the queries and output results there. You can catch the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a databases.php script that passes options to con_query.php the code could something like that: *databases.php:* ?php $label = Choose a database :; $database = array('database1','database3','database3'); # Print the headers print 'htmlheadmeta http-equiv=content-type content=text/html; charset=UTF-8titleDatabase selection/title/headbody no-repeat;'; print 'table class=outer border=0 width=100% cellpadding=10 cellspacing=10'; print ' trtd height=92px colspan=2/td/tr'; # Print the drop down form print form name='dtbases' action='con_query.php' method='POST'; print 'table border=0 trtdtable class=invistrtdnbsp;/td/tr'; print trtdb$label/b/tdtdselect name='database'; foreach ($database as $value){ print option value='$value'$value/option; } print /td/tr/select; print trtdnbsp;/td/tr; print trtd colspan=2 align=centerinput type=submit value='Submit'/td/tr; ? *con_query.php:* ?php $database = $_REQUEST['database']; print The user chose database : .$database; ? You can take now the $database containing the one chosen by the user and connect and query whatever you wan't. Have fun. mike wrote: On 8/23/07, Suamya Srivastava [EMAIL PROTECTED] wrote: Hello, How can I pass variables on clicking a hyperlink to a PHP script? I have 5 hyperlinks, all pointing to the same PHP script. However, on clicking each hyperlink a different value of the variable needs to be passed to the PHP script. i.e. I have 5 databases from which I want to obtain information, however the information should be displayed only when the user clicks on the hyperlink for that database. How can I pass the database name to the PHP script? How would the script know which database to get information from? I am new to PHP so any help would be greatly appreciated. I hope my question is clear. use GET foo.php?param=value or you could use POST by using some client-side javascript to do a form submit with key/value pairs. this is a *very* simple operation... all web-enabled languages understand HTTP POST/GET/etc. - those are the main ways of exchanging data between client/server.
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
I thought I just did a comment and suggested that it is a lame solution to use $_REQUEST plus I did not know witch of the two method (POST or GET) would be appropriate so I picked up the lame way :-) . mike wrote: On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
Thank you all for the help. I did not want to use dropdown box..that was the very reason i was wondering if I can pass the variables through a hyperlink. I used $_GET and it worked fine. However, as mentioned in the posts its not advisable to use $_REQUEST. Could you please elaborate on the reason? This brings me to another question I have registered a variable as a session variable so that I can use it on any page during that session. HOwever, this was not working when I first tried it. I read somewhere that I need to enable register_globals. On doing so, it worked and I could access my session variable on any other page. Is this wrong? Is there an alternative? Please suggest. - suamya On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
In this case $_POST would be the appropriate array, since your form is using the POST method: form method=post Goltsios Theodore wrote: I thought I just did a comment and suggested that it is a lame solution to use $_REQUEST plus I did not know witch of the two method (POST or GET) would be appropriate so I picked up the lame way :-) . mike wrote: On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
Hi.. in the settings, session.use_cookies is turned ON but session.trans_sid is turned OFF. do i need to enable this as well? by doing this can i disable the register_globals? - suamya Hi Me again Check on Your setting - ; Whether to use cookies. session.use_cookies = 1 session variable is saved here if the user have cookies turned off it will still work if your have trans-sid turn on. BTW you don't have to use a dropdown radio buttons or tick box will work as well Johan Suamya Srivastava [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thank you all for the help. I did not want to use dropdown box..that was the very reason i was wondering if I can pass the variables through a hyperlink. I used $_GET and it worked fine. However, as mentioned in the posts its not advisable to use $_REQUEST. Could you please elaborate on the reason? This brings me to another question I have registered a variable as a session variable so that I can use it on any page during that session. HOwever, this was not working when I first tried it. I read somewhere that I need to enable register_globals. On doing so, it worked and I could access my session variable on any other page. Is this wrong? Is there an alternative? Please suggest. - suamya On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
Hi Me again Check on Your setting - ; Whether to use cookies. session.use_cookies = 1 session variable is saved here if the user have cookies turned off it will still work if your have trans-sid turn on. BTW you don't have to use a dropdown radio buttons or tick box will work as well Johan Suamya Srivastava [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thank you all for the help. I did not want to use dropdown box..that was the very reason i was wondering if I can pass the variables through a hyperlink. I used $_GET and it worked fine. However, as mentioned in the posts its not advisable to use $_REQUEST. Could you please elaborate on the reason? This brings me to another question I have registered a variable as a session variable so that I can use it on any page during that session. HOwever, this was not working when I first tried it. I read somewhere that I need to enable register_globals. On doing so, it worked and I could access my session variable on any other page. Is this wrong? Is there an alternative? Please suggest. - suamya On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
Hi Here is my 2cents I will not use GET. If you want to pass a db name i would use POST. Because if you don't do something with the statusbar the the user can see the dbname if you use GET and i don't think that is a good thing. I'm working on an webbased app with a lot of db work and i learnt Don't trust the user not even if it is just the intranet. There my 2cents Goltsios Theodore [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I thought I just did a comment and suggested that it is a lame solution to use $_REQUEST plus I did not know witch of the two method (POST or GET) would be appropriate so I picked up the lame way :-) . mike wrote: On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
Hi I have sessions working like a charm, i use it for my user login vars and so on, here is the settings i used. register_globals = Off session.use_cookies = 1 and switch on session.trans_sid if you know that not all your users will have cookies turned on This worked for me Johan Suamya Srivastava [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi.. in the settings, session.use_cookies is turned ON but session.trans_sid is turned OFF. do i need to enable this as well? by doing this can i disable the register_globals? - suamya Hi Me again Check on Your setting - ; Whether to use cookies. session.use_cookies = 1 session variable is saved here if the user have cookies turned off it will still work if your have trans-sid turn on. BTW you don't have to use a dropdown radio buttons or tick box will work as well Johan Suamya Srivastava [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thank you all for the help. I did not want to use dropdown box..that was the very reason i was wondering if I can pass the variables through a hyperlink. I used $_GET and it worked fine. However, as mentioned in the posts its not advisable to use $_REQUEST. Could you please elaborate on the reason? This brings me to another question I have registered a variable as a session variable so that I can use it on any page during that session. HOwever, this was not working when I first tried it. I read somewhere that I need to enable register_globals. On doing so, it worked and I could access my session variable on any other page. Is this wrong? Is there an alternative? Please suggest. - suamya On 8/24/07, Goltsios Theodore [EMAIL PROTECTED] wrote: the posted or got option buy using the $_REQUEST array ($_GET and $_POST are included in that like a less lame solution). Let's say you have a Please do not encourage the use of $_REQUEST. You might as well just tell people to enable register_globals again. Use $_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER, etc. for the appropriate source of data. $_REQUEST is laziness and introduces most of the same issues that was the reasoning behind disabling register_globals to begin with. (As for dropdowns, that's just an in-browser method of collecting data and sending the key/value pairs in POST or GET... IMHO the HTML portion should already be known before someone steps into the realm of PHP and server-side programming) - mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink
On 8/24/07, Suamya Srivastava [EMAIL PROTECTED] wrote: Hi.. in the settings, session.use_cookies is turned ON but session.trans_sid is turned OFF. do i need to enable this as well? by doing this can i disable the register_globals? - suamya You need to make sure session_start() is called on all pages to be able to read/write the session data. This is probably the case. I have never needed to use trans_sid. It introduces some complexities that I don't think are needed. $_REQUEST is basically a new way of doing register_globals, which is a security issue. register_globals can allow a savvy user to overwrite a variable with another source - say you wanted a POST variable, a user could supply GET instead. or if you want it to come from a cookie using $_COOKIE it could be overridden using GET. If that makes sense. There's a lot of information about it. It was disabled by default a while back. Never enable it. You do not need it, period. Anyone telling you to enable it or reading somewhere you need to enable it is *absolutely* incorrect. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] $db=new mysqli fails while $db=mysqli_connect succeeds in PHP/MySQL 5
From a php-general thread earlier: ?php $db=new mysqli('localhost','whil','secret','test'); ? generates: Fatal error: Call to undefined function new mysqli() in index.php on line 24 while ?php $conn = mysqli_connect(localhost,whil,secret,test); echo 'conn good: '.$conn.' :very good indeedbr'; ? generates success: conn good: Object id #1 :very good indeed The book I'm working with (PHP MySQL Web Dev, Welling/Thompson) specifically defines the 'new mysqli' syntax. So I'm guessing I don't have something configured right? Whil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Looking for some help on a project!
Hello, im working on making a custom CMS for my new site which will have tons of tutorials all about technology, and will have forums, and news, and stuff. But, its such a big undertaking, that I need help! If your willing to help me, I can give you FTP access, and database access. Just post here if your interested with your name and way of contact, and post some examples of your work, because I want people who understand PHP MySQL. --
RE: [PHP-DB] Looking for some help on a project!
Why not look at mambo or drupal to provide the framework? Be a lot quicker than coding it from scratch bastien Date: Fri, 24 Aug 2007 23:18:48 -0500 From: [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Looking for some help on a project! Hello, im working on making a custom CMS for my new site which will have tons of tutorials all about technology, and will have forums, and news, and stuff. But, its such a big undertaking, that I need help! If your willing to help me, I can give you FTP access, and database access. Just post here if your interested with your name and way of contact, and post some examples of your work, because I want people who understand PHP MySQL. -- _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us