Hi DPers, I want to create an API that uses a single variable within the URL. ie: lookup.php?var1=VARIABLE1 I also want the script to log the variable to a mysql database. How do I get the script to read the variable, use it, and log it to a database? I searched everywhere and couldn't find an answer... (sorry, I'm a PHP noob ) EDIT: I also want to turn the variable into $variable within the script. Is this possible?
You use $_GET['var1'] there yo. Like this <?php if(isset($_GET['var1'])) { $lol = $_GET['var1']; echo $lol; echo $_GET['var1']; } ?> PHP: I suggest that you read this tutorial from top to bottom. And be patient
Can I use this method with multiple variables such as query.php?var1=VARIABLE1&var2=VARIABLE2 ? And would the code be this: <?php if(isset($_GET['var1'])) { $lol = $_GET['var1']; } if(isset($_GET['var2'])) { $lol2 = $_GET['var2']; } echo $lol; echo $lol2; ?> PHP: ???
Notie that if one of the variables is not set you will get an error when trying to echo one of them. You should echo it inside the if statements
hello, I am developing a site, everything fine till url rewrite but my url rewrite function is not working now.. my urls seems like rentalnetworks.com/main-1-sub-2-cisco-network-switches.html, i have to remove main-1-sub-2- to make seo friendly urls.. would you please give me solutions for this.