PHP - How To Query Multiple Search Pages
Hi guys,
I have a php file that will go to a site and scrape the data I need. However this site is setup to use pagination so when I try to scrape all the players names I have to do separate queries to search each page. Is there a way to find out by using code how many pages there are and query all the pages at same time? I use this code Code: [Select] <?php //first page //turn error reporting on libxml_use_internal_errors(true); //get data from this page $dom = new DOMDocument; $dom->loadHTMLFile('http://www.gametracker.com/server_info/76.73.3.42:1716/top_players/?searchipp=50#search'); $xpath = new DOMXPath($dom); // Get the total player count $rows2 = $xpath->query('//div[@class="block774"]/div'); // Get the rows from the search list $rows = $xpath->query('//table[@class="table_lst table_lst_spn"]/tr'); for ($i=1; $i<$rows->length-1; $i++) { $row = $rows->item($i); // Get the columns for a row $cols = $row->getElementsByTagName('td'); // Get the player rank (1st column) echo 'Rank:'.trim($cols->item(0)->textContent).PHP_EOL; // Get the player name (2nd column) echo 'Name:'.trim($cols->item(1)->textContent).PHP_EOL; // Get the player score (3rd column, actually 4th but number 3 is hidden) echo 'Sco '.trim($cols->item(3)->textContent).PHP_EOL; echo "<br />"; } ?> <?php //secondpage //turn error reporting on libxml_use_internal_errors(true); //get data from this page $dom = new DOMDocument; $dom->loadHTMLFile('http://www.gametracker.com/server_info/76.73.3.42:1716/top_players/?searchipp=50&searchpge=2#search'); $xpath = new DOMXPath($dom); // Get the rows from the search list $rows = $xpath->query('//table[@class="table_lst table_lst_spn"]/tr'); for ($i=1; $i<$rows->length-1; $i++) { $row = $rows->item($i); // Get the columns for a row $cols = $row->getElementsByTagName('td'); // Get the player rank (1st column) echo 'Rank:'.trim($cols->item(0)->textContent).PHP_EOL; // Get the player name (2nd column) echo 'Name:'.trim($cols->item(1)->textContent).PHP_EOL; // Get the player score (3rd column) echo 'Sco '.trim($cols->item(3)->textContent).PHP_EOL; echo "<br />"; } ?> I also have to go to that website first to see how many pages there are so I can have enough queries. Similar TutorialsHello everyone, Very new to coding - enjoying it but struggling! I think I'm trying to do something pretty common but I seem to have come up against a complete wall now and after hours/days searching the internet and reading books I'm completely stuck! I'm trying to write some code to search a MySQL database of products, then display the results. For some search results there will be lots of products so I want to display 10 products on the first page then allow visitors to go to the next page to see another 10, and so on - a type of pagination, as they should then be able to click back to see the last page etc. I've got to the point of being able to display the first 10 search results, but I can't figure out at all how to create some kind of page scrolling/pagination system. Please, does anybody have any ideas?? I've attached my code, I hope this is the correct way of doing things here. Many thanks for your time! The PHP search code... Code: [Select] <?php //opens connection to mysql server $dbc = mysql_connect('localhost'); if (!$dbc) { die('Not connected :' . mysql_error()); } echo "Connected to mysql database<br />"; //select database $db_selected = mysql_select_db("NAME_OF_DATABASE", $dbc); if (!$db_selected) { die ("Cannot connect :" . mysql_error()); } echo "Connected to database<br /><hr />"; echo "Here are your results"; $term = $_POST['term']; $category = $_POST['category']; $brand = $_POST['brand_name']; $sql = mysql_query("SELECT * FROM products where product_name like '%$term%' AND category_name like '%$category%' AND brand_name like '%$brand%' LIMIT 0, 10"); { while ($row = mysql_fetch_array($sql)){ echo "<table border='1' width='100%'> "; echo "<tr>"; echo "<td style='vertical-align:top' width='25%'>" . '<img src="', $row['image_url'], '" alt="', $row['product_name'], '" width="100" height="100" />' . "</td>"; echo "<td style='vertical-align:top' width='50%'>" . $row['product_name']; echo "<br />"; echo "<span style='font-size: 10px'>" . $row['description'] . "</span>" . "</td>"; echo "<td style='vertical-align:top' width='25%'>" . $row['price']; echo "<br />"; echo "<br />"; echo "<hr />"; echo "$row['merchant_name'] </td>"; echo "</tr>"; } echo "</table>"; } ?> After a few days of searching and running across a problem what is almost like mine on these forums (cant seem to find the link now) where the person was looking to search a database using checkboxes. What I am trying to do is use a list of checkboxes (http://www.animeseason.com/anime-list/categories/) exactly like this link and search my table which has the genres as columns. I am new to PHP and don't really have a starting point. I have taken a bunch of examples and came up with this. My HTML form with a list of all my checkboxes. Code: [Select] <form method="post" ACTION = "php/do_search.php"> <ul class="cat_col"> <li><input type="checkbox" name="cat_check[]" value="1"> <a href="#Action">Action</a></li> <li><input type="checkbox" name="cat_check[]" value="2"> <a href="#Adventure">Adventure</a></li> <li><input type="checkbox" name="cat_check[]" value="3"> <a href="#Comedy">Comedy</a></li> <li><input type="checkbox" name="cat_check[]" value="4"> <a href="#Demons">Demons</a></li> <li><input type="checkbox" name="cat_check[]" value="5"> <a href="#Drama">Drama</a></li> <li><input type="checkbox" name="cat_check[]" value="6"> <a href="#Ecchi">Ecchi</a></li> <li><input type="checkbox" name="cat_check[]" value="7"> <a href="#Fantasy">Fantasy</a></li> <li><input type="checkbox" name="cat_check[]" value="8"> <a href="#Harem">Harem</a></li> <li><input type="checkbox" name="cat_check[]" value="9"> <a href="#Horror">Horror</a></li> <li><input type="checkbox" name="cat_check[]" value="10"> <a href="#Magic">Magic</a></li> <li><input type="checkbox" name="cat_check[]" value="11"> <a href="#Martial Arts">Martial Arts</a></li> <li><input type="checkbox" name="cat_check[]" value="12"> <a href="#Mecha">Mecha</a></li> <li><input type="checkbox" name="cat_check[]" value="13"> <a href="#Music">Music</a></li> </ul> <ul class="cat_col"> <li><input type="checkbox" name="cat_check[]" value="14"> <a href="#Mystery">Mystery</a></li> <li><input type="checkbox" name="cat_check[]" value="15"> <a href="#Ninja">Ninja</a></li> <li><input type="checkbox" name="cat_check[]" value="16"> <a href="#Parody">Parody</a></li> <li><input type="checkbox" name="cat_check[]" value="17"> <a href="#Psychological">Psychological</a></li> <li><input type="checkbox" name="cat_check[]" value="18"> <a href="#Reverse Harem">Reverse Harem</a></li> <li><input type="checkbox" name="cat_check[]" value="19"> <a href="#Romance">Romance</a></li> <li><input type="checkbox" name="cat_check[]" value="20"> <a href="#Samurai">Samurai</a></li> <li><input type="checkbox" name="cat_check[]" value="21"> <a href="#School Life">School Life</a></li> <li><input type="checkbox" name="cat_check[]" value="22"> <a href="#Science Fiction">Science Fiction</a></li> <li><input type="checkbox" name="cat_check[]" value="23"> <a href="#Seinen">Seinen</a></li> <li><input type="checkbox" name="cat_check[]" value="24"> <a href="#Shoujo">Shoujo</a></li> <li><input type="checkbox" name="cat_check[]" value="25"> <a href="#Shounen">Shounen</a></li> <li><input type="checkbox" name="cat_check[]" value="26"> <a href="#Slapstick">Slapstick</a></li> </ul> <ul class="cat_col"> <li><input type="checkbox" name="cat_check[]" value="27"> <a href="#Slice of Life">Slice of Life</a></li> <li><input type="checkbox" name="cat_check[]" value="28"> <a href="#Sports">Sports</a></li> <li><input type="checkbox" name="cat_check[]" value="29"> <a href="#Supernatural">Supernatural</a></li> <li><input type="checkbox" name="cat_check[]" value="30"> <a href="#Thriller">Thriller</a></li> <li><input type="checkbox" name="cat_check[]" value="31"> <a href="#Tragedy">Tragedy</a></li> <li><input type="checkbox" name="cat_check[]" value="32"> <a href="#Vampire">Vampire</a></li> </ul> <ul class="cat_col"> <li><input type="checkbox" name="cat_check[]" value="33"> <a href="#Movie">Movie</a></li> <li><input type="checkbox" name="cat_check[]" value="34"> <a href="#OVA">OVA</a></li> <li><input type="checkbox" name="cat_check[]" value="35"> <a href="#Top Rated">Top Rated</a></li> <li><input type="checkbox" name="cat_check[]" value="36"> <a href="#Currently Airing">Currently Airing</a></li> <li><input type="checkbox" name="cat_check[]" value="37"> <a href="#Ended">Ended</a></li> <li><input type="checkbox" name="cat_check[]" value="38"> <a href="#Ongoing">Ongoing</a></li> </ul> <div id="submit_btn_pos"> <input type="submit" name="search" value="Lets Make Magic" class="submit_btn"> <> </form> My PHP script that right now seems to do nothing. Code: [Select] <?php //if we got something through $_POST if (isset($_POST['cat_check'])) { $con = mysql_connect("localhost","USERNAME","PASSWORD") or die("Connection error"); mysql_select_db("DATABASENAME")or die("database doesn't exist"); // sanitize user input $cleanData = array(); foreach($_POST['cat_check'] as $_comp) { //$cleanData = mysql_real_escape_query($_comp); } // Build query $compStr = implode("'), ('", $cleanData); $sql = "SELECT anime_name WHERE $_comp='1'"; } ?> My database has a layout of "Name of show, (every genere listed above)". Thanks for any help. I want to have a search product feature, but I would like members to be able to search multiple fields in one go i.e. product_code, Product_name in one MySQL query. The thing is, members have to be logged on, so the query must also only show results relating to that specific member, via the session[member_ID], my current query for listing products for that specific member is : Code: [Select] $sql = "SELECT productId, productCode, image, name, price, stock_level FROM product_inventory WHERE memberr_ID = '" . $_SESSION['SESS_mem_ID'] . "; How would I change the above into a search query to search for productcode, productname and still only show results beloging to this member using the session data ? all help appreciated Hello, Does anyone know a tutorial I can follow to create my own search engine over the items I have in my SQL database? I find a lot of tutorials but they are all 'one word searches' which means if you type two words you will get all results that contain either word (too many hits). If the search engine tutorial displays result with AJAX even better. Thanks for help. df Hi all How do I modify the below code to search multiple tables in mySQL database? $query = "select * from store_items where description like \"%$trimmed%\" or title like \"%$trimmed%\" or dimensions like \"%$trimmed%\" order by id ASC"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); It is for a search function and I need it to search another table called 'about_text' and 'faq_text' Thanks Pete This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351561.0 hello, i have made the fallowing code that searches through my mysql database in oder to find something looks like the query that the user is looking for. i was just wondering what should i do in order to make a second page if the results are more than 25. in other words, if there are more than 25 row i want to have a second page and if its more than 50 i want a third page and so on. $searchquery=$_POST['searchquery']; $sql = "SELECT * FROM users WHERE title ILKE '%" . $letter . "%'"; $result = mysql_query($sql); $numrows=mysql_num_rows($result); echo "<p align="center">" .$numrows . " results found for " . $letter . "</p>"; if ($numrows != 0) { ?> <table border="1" style="border-bottom-style:inherit"> <tr> <td bgcolor="#CCCCCC" style="width: 95px"><strong>image</strong></td> <td width="450" bgcolor="#CCCCCC"><strong>Description</strong></td> <td width="100" bgcolor="#CCCCCC"><strong>Book Price</strong></td> <td width="100" bgcolor="#CCCCCC"><strong>Asked Price</strong></td> </tr> <? while($row=mysql_fetch_array($result)){ ?> <tr> <td style="width: 95px"> <img src="CardsPictures/<? echo $row['cardid']; ?>.jpg" width="71" height="96" alt="Front Picture"/></td> <td><a href="http://www.SportsCardMovers.com/show_card.php?cardid=<? echo $row['cardid']; ?>"><? echo $row['title']; ?></a></td> <td><? echo $row['bookprice']?></td> <td><? echo $row['price']?></td> <? } ?> </tr> </table> <? } else echo "Please Use another Query and Search Again"; ?> thank you does anyone have a code todo this? a snippet or soemthing ive tried a few diffrent ones ive seen but nothing that works.. it takes whats submited in search, then takes the words, breaks them up and creates a query string with all the diffrent feilds... here is what phpadmin produces when i search SELECT * FROM `breedclads`.`activeamahorse` WHERE (`id_entered` LIKE '%green%' OR `uuid` LIKE '%green%' OR `ama_hr_coat` LIKE '%green%' OR `breedable` LIKE '%green%' OR `ama_hr_sex` LIKE '%green%' OR `ama_hr_age` LIKE '%green%' OR `date_entered` LIKE '%green%' OR `ama_hr_eyes` LIKE '%green%' OR `ama_hr_eyes_type` LIKE '%green%' OR `ama_hr_mane` LIKE '%green%' OR `ama_hr_tail` LIKE '%green%' OR `ama_hr_luster_coat` LIKE '%green%' OR `ama_hr_luster_hair` LIKE '%green%' OR `ama_hr_gleam_coat` LIKE '%green%' OR `ama_hr_gleam_hair` LIKE '%green%' OR `ama_hr_parents` LIKE '%green%' OR `ama_hr_sale_type` LIKE '%green%' OR `ama_hr_sale_price` LIKE '%green%' OR `ama_hr_location` LIKE '%green%' OR `auction_date` LIKE '%green%' OR `picture_type` LIKE '%green%' OR `picture_name` LIKE '%green%' OR `picture_size` LIKE '%green%' OR `picture_content` LIKE '%green%' OR `ama_hr_coat_type` LIKE '%green%' OR `ama_hr_coat_gloom` LIKE '%green%' OR `ama_hr_hair_gloom` LIKE '%green%' OR `ama_hr_slurl` LIKE '%green%' OR `class_link_key` LIKE '%green%') AND (`id_entered` LIKE '%albino%' OR `uuid` LIKE '%albino%' OR `ama_hr_coat` LIKE '%albino%' OR `breedable` LIKE '%albino%' OR `ama_hr_sex` LIKE '%albino%' OR `ama_hr_age` LIKE '%albino%' OR `date_entered` LIKE '%albino%' OR `ama_hr_eyes` LIKE '%albino%' OR `ama_hr_eyes_type` LIKE '%albino%' OR `ama_hr_mane` LIKE '%albino%' OR `ama_hr_tail` LIKE '%albino%' OR `ama_hr_luster_coat` LIKE '%albino%' OR `ama_hr_luster_hair` LIKE '%albino%' OR `ama_hr_gleam_coat` LIKE '%albino%' OR `ama_hr_gleam_hair` LIKE '%albino%' OR `ama_hr_parents` LIKE '%albino%' OR `ama_hr_sale_type` LIKE '%albino%' OR `ama_hr_sale_price` LIKE '%albino%' OR `ama_hr_location` LIKE '%albino%' OR `auction_date` LIKE '%albino%' OR `picture_type` LIKE '%albino%' OR `picture_name` LIKE '%albino%' OR `picture_size` LIKE '%albino%' OR `picture_content` LIKE '%albino%' OR `ama_hr_coat_type` LIKE '%albino%' OR `ama_hr_coat_gloom` LIKE '%albino%' OR `ama_hr_hair_gloom` LIKE '%albino%' OR `ama_hr_slurl` LIKE '%albino%' OR `class_link_key` LIKE '%albino%') AND (`id_entered` LIKE '%69%' OR `uuid` LIKE '%69%' OR `ama_hr_coat` LIKE '%69%' OR `breedable` LIKE '%69%' OR `ama_hr_sex` LIKE '%69%' OR `ama_hr_age` LIKE '%69%' OR `date_entered` LIKE '%69%' OR `ama_hr_eyes` LIKE '%69%' OR `ama_hr_eyes_type` LIKE '%69%' OR `ama_hr_mane` LIKE '%69%' OR `ama_hr_tail` LIKE '%69%' OR `ama_hr_luster_coat` LIKE '%69%' OR `ama_hr_luster_hair` LIKE '%69%' OR `ama_hr_gleam_coat` LIKE '%69%' OR `ama_hr_gleam_hair` LIKE '%69%' OR `ama_hr_parents` LIKE '%69%' OR `ama_hr_sale_type` LIKE '%69%' OR `ama_hr_sale_price` LIKE '%69%' OR `ama_hr_location` LIKE '%69%' OR `auction_date` LIKE '%69%' OR `picture_type` LIKE '%69%' OR `picture_name` LIKE '%69%' OR `picture_size` LIKE '%69%' OR `picture_content` LIKE '%69%' OR `ama_hr_coat_type` LIKE '%69%' OR `ama_hr_coat_gloom` LIKE '%69%' OR `ama_hr_hair_gloom` LIKE '%69%' OR `ama_hr_slurl` LIKE '%69%' OR `class_link_key` LIKE '%69%') i need this to be made when people search with mutliple words as you can see it searchs each feilds for the green then each feild for albino, so on.. but i wont ever know what there searching for Please help me, thanks Need help to correct my cording! I want to limited search results by 5 items on one page.
Don't know how correctly to add limit: "limit $page1,5".
When I add it: $sql = "SELECT * FROM data GROUP BY city ORDER BY city limit $page1,5";
it doesn't limit searching result by pages.
Attached Files
search3.php 1.67KB
5 downloads Hello. I'm coding myself an small webpage, In the internet you can see that there is pages like index.php?id=223923 <- for example or index.php?=news. So, I'm trying to create similar to that myself. I tried googling and searching youtube how to do this but didn't really find anything. I figured it out that it needs some database etc. I tried myself doing some table in my mysql db. And in the table some 'id, title, content' and in the id would be the url, (index.php?='id') the title would be the <title> </title> and the content would be all the code inside the webpage. I got no idea how to link these to an php or whatever it should be done So would anyone kindly tell me howto do this or give some link to an tutorial? Hey guys, how is everyone today? I am needing a little help with this one. I have a database that updates itself and the display page for it with every form submission on the website. I am wondering how I go about getting it to display across multiple pages? For example, once it hits 25 submissions, it would make a page 2, once page two hits 25 submissions, it creates page 3, etc. etc. Much like you see on something like a forum, it hits so many replies before it creates a new page, to limit one long page of results. Thanks in advance!! I've read through a few examples of how to paginate query results, but with my currently php skills I don't understand them, or they do not fit into my code. I wondered if I could make my own, and the logic behind this code makes sense to me, but it's still not working. Here is the code: <?php if (!$Start) { $Start = 0; } else { $Start=$_POST['Start']; } $crittercount = 120; $numpages = $crittercount / 30; $pagei = 1; $pagereit = 1; echo '<p><center> <FORM method=POST action=testpagination.php> <SELECT NAME="Start"> <OPTION>Page 1'; while ($pagereit < $numpages) { $pagei = $pagei + 30; echo '<OPTION value='.$pagei.'>'; $pagereit = $pagereit + 1; echo "Page: " .$pagereit; } echo '</SELECT>'; echo'<input type=submit value=Go></FORM><p>'; echo $Start; ?> The test site is he http://lab-lib.com/felishorns/Felishorns/websitetest/testpagination.php $crittercount is a variable that changes depending on the main $query. This query is invisible, and is used to pull a count for all the results in total. I am modifying it with $Start to create a second query which the viewer sees. $queryF = $query . " LIMIT " . $Start . ", 30"; The idea is that $Start changes depending on the value selected, thereby changing the query. In this test code, I've simply echoed the $Start value of that page, to see if the code is working, and it's not changing. What's wrong with this code? Is it not possible to have a form lead to the same link of the page it's on? Does the variable not become updated? Thanks in advance. HY I have index.php and pictures.php. In index.php I have 3 columns: - left (for menu) - right (for advertising) - center (where I want to include pictures.php) What is the best way to include pictures.php in center of index.php Code: [Select] if($_get[pictures]){ include ("pictures.php"); } I ask this because I have multiple variable like "pictures" and I will have multiple "If". Or to include in DB all this variables "pictures" and just add ".php" extension. It is secure in this way ? Thanks In the code below, I am trying to produce a google-like page where the user can type keywords and pages of search results are displayed. The main difficulty I am encountering is that when the browser changes pages, it forgets everything about current data. Perhaps I should include the display of pages inside the HTML form ? How can I fix this code ? Here is the contents of my searchpage.php file : <?php $keywords=''; $display_search_results=''; if(isset($_POST['search_submitted'])) { $keywords=$_POST['keywords']; $search_results=array(); $totalNbrOfItems=20; for($k=1;$k<=$totalNbrOfItems;$k++) { $search_results[$k]='Your keywords '$keyowrds.' have been found in item number '.$k; } $nbrOfItemsParPage = 5; $nbrOfPages = ceil($totalNbrOfItems / $nbrOfItemsParPage); // Compute current page $current_page = (isset($_GET['page']))?intval($_GET['page']):1; $display_pages=($nbrOfPages<2)?'<p>Page : ':'<p>Pages : '; for ($i = 1 ; $i <= $nbrOfPages ; $i++) { if ($i == $current_page) //No link to the current page { $display_pages=$display_pages.$i.' '; } else { $display_pages=$display_pages.'<a href="searchpage.php?'. 'page='.$i.'">'. $i . '</a> '; } } $display_pages=$display_pages.'</p>'; $display_items=''; $start=$nbrOfItemsPerPage*($current_page-1); for($k=1;$k<=$nbrOfItemsParPage;$k++) { $display_items=$display_items.($search_results[$start+$k]).'<br>'; } $display_search_results=$display_pages.$display_items; } echo '<form method="post" action="searchpage.php">'. ' Type your keywords here : <br><br>'. '<textarea cols="65" rows="1" '. 'id="keywords_id" name="keywords">'.$keywords.'</textarea>'. '<input type="submit" name="search_submitted" id="search_submitted_id" value="Search" /> '. '</fieldset>'. '</form>'; echo $display_search_results; ?> Hello Everyone was wondering if I could get some help with the following code? I am querying a database for results of listings that are in a database these listings are displayed on the page in a form. I am wanting each listing to be on a different page. Below is my code. Code: [Select] $lim=1; if (!isset($s) || $s < 1 || !is_numeric($s)) { $s = 1; } $start = ($s - 1) * $lim; $sql = "select id,bussimg,imagewidth,imageheight,email,usridm,company,businesscategory,address1,address2,state,city,zip,website,email,repname,description,phonenumber,country,status from $approvecheckbusinesses where usridm='$user_id'"; $result=db_query($sql); $countpages = $sql; $sql = $sql . " order by id asc limit $start, $lim"; $result=db_query($sql); $pages = ceil(mysql_num_rows(mysql_query($countpages)) / $lim); $result=db_query($sql); for ($i = 0; $i < mysql_num_rows($result); $i++) { $Listid= mysql_result($result, $i, "id"); $usridm= mysql_result($result, $i, "usridm"); $CompanyName= mysql_result($result, $i, "company"); $realname= mysql_result($result, $i, "repname"); $email= mysql_result($result, $i, "email"); $BusinessCategory= mysql_result($result, $i, "businesscategory"); $status= mysql_result($result, $i, "status"); echo ("FORM IS TO BE DISPLAYED HERE"); } if ($pages > 1) { echo("<p align=left style='font-size: 85% color=white'>"); for ($i = 1; $i <= $pages; $i++) { echo("["); if ($i == $s) {echo("<b>");} else {echo("<a id=home_offerLink href='index.html?EditMemberListing&user_id=$user_id&s=$i'>");} echo("Page $i"); if ($i == $s) {echo("</b>");} else {echo("</a>");} echo("] "); } echo("</p>") Page Numbers here using the above code.. The problem I seem to be running into is that it only displats the first record. The page numbers show up page 1 page 3 page 2 and three are blank there is no mysql error or anything for some reason I only get that first result out of three I am creating a webpage for my golf league and some of the information(variables) such as Name, Address and email, must be reused across multiple pages for different outputs. May question is "Can I, or is there a way to reUse variables across multiple pages. "Do I need to create a session and make everything session variables"? "Should I link to a database and call the information when needed"? Any explanation would be greatly appreciated. Hi, I have some code which scrapes data from a page. However there are around 1200 product pages on the site I need to scrape, when I attempt to loop through all the pages I get a server timeout. I can only get to around 40 without timeout. Has anyone else had this problem? I have an ordering process that consists of 3 pages: 1) Page1: Enter name/address 2) Page2: Based on address, determine availability of products, and let user choose which products, how many, etc. 3) Page3: Enter credit card info to send to the processor What is the best way to store information fro page 1 to page 2, then from page 2 to page 3? I thought about just using hidden fields. Is this OK? Is there another preferred way? Thanks! I'm am somewhat new to PHP and am trying to set up a website for my cousin's wedding. Her idea is to have the guests sign in with a user/pass that she provides, and once they sign in, they will be taken to a page that has their name on it (i.e. "Mr. and Mrs. So and So, you are invited...). I have come to the conclusion that I will need to make an image for each guest's name (she wants to use a font for their names that nobody will have on their computer) so what I need to know is: How do I link each user name to their own personalized webpage, where the image of their name on the next page will change based on what username is entered? I have been told to use Sessions (which I don't yet have in this code), but I'm clueless as to how to make that work for multiple users. Where do I put the coding, what does the coding look like, etc. Thanks in advance for any help! The php code I have right now is this (i'm sorry it's so long, I just don't want to leave anything out that might be important): Code: [Select] $LOGIN_INFORMATION = array( 'steve' => 'password', 'rick' => 'password', 'tom'=> 'password' ); // request login? true - show login and password boxes, false - password box only define('USE_USERNAME', true); // User will be redirected to this page after logout define('LOGOUT_URL', 'http://www.example.com/'); // time out after NN minutes of inactivity. Set to 0 to not timeout define('TIMEOUT_MINUTES', 0); // This parameter is only useful when TIMEOUT_MINUTES is not zero // true - timeout time from last activity, false - timeout time from login define('TIMEOUT_CHECK_ACTIVITY', true); ################################################################## # SETTINGS END ################################################################## /////////////////////////////////////////////////////// // do not change code below /////////////////////////////////////////////////////// // show usage example if(isset($_GET['help'])) { die('Include following code into every page you would like to protect, at the very beginning (first line):<br><?php include("' . str_replace('\\','\\\\',__FILE__) . '"); ?>'); } // timeout in seconds $timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60); // logout? if(isset($_GET['logout'])) { setcookie("verify", '', $timeout, '/'); // clear password; header('Location: ' . LOGOUT_URL); exit(); } if(!function_exists('showLoginPasswordProtect')) { // show login form function showLoginPasswordProtect($error_msg) { ?> <html> <head> <title>Please enter password to access this page</title> <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> body,td,th { font-family: Verdana, Geneva, sans-serif; font-size: 10px; color: #666; } body { background-color: #FFFFFB; } </style> </head> <body> <div align="center"> <style> input { border: 1px solid black; } </style> <div style="width:600px; margin-left:auto; margin-right:auto; text-align:center"> <form method="post"> <h4>Please sign in using the information provided on the invitation</h4> <font color="red"><?php echo $error_msg; ?></font><br /> <?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Password:<br />'; ?> <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Submit" /> </form> <br /> <a style="font-size:9px; color: #B0B0B0; font-family: Verdana, Arial;" href="http://www.zubrag.com/scripts/password-protect.php" title="Download Password Protector">Powered by Password Protect</a> </div> </body> </html> <?php // stop at this point die(); } } // user provided password if (isset($_POST['access_password'])) { $login = isset($_POST['access_login']) ? $_POST['access_login'] : ''; $pass = $_POST['access_password']; if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION) || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) ) { showLoginPasswordProtect("Incorrect password."); } else { // set cookie if password was validated setcookie("verify", md5($login.'%'.$pass), $timeout, '/'); // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed // So need to clear password protector variables unset($_POST['access_login']); unset($_POST['access_password']); unset($_POST['Submit']); } } else { // check if password cookie is set if (!isset($_COOKIE['verify'])) { showLoginPasswordProtect(""); } // check if cookie is good $found = false; foreach($LOGIN_INFORMATION as $key=>$val) { $lp = (USE_USERNAME ? $key : '') .'%'.$val; if ($_COOKIE['verify'] == md5($lp)) { $found = true; // prolong timeout if (TIMEOUT_CHECK_ACTIVITY) { setcookie("verify", md5($lp), $timeout, '/'); } break; } } if (!$found) { showLoginPasswordProtect(""); } } ?> |