Jump to content

reggie

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by reggie

  1. I have just completed a php site that uses mysql database. I have created a member site, with register, login, search etc.The search facility allows members to search for other members and lists them. Once a member clicks another members search result, they then can view their profile and send a message, but never see email addresses.How can i set it up to display a button / link next to each list result and store that email address in a cookie or session such as an array or something email[x] = $rowAnd is there a way to send the message to all email addresses stored, or is this to complicated.
  2. reggie

    Listing Records

    OK. I have completed a search that should have found 4 matching records. I wanted to show 2 recrods per page so i set the limit to 2. It listed 2 records that were found and this was the outcome:s: 0limit: 2pages: 1Showing results 1 to 2 of 2.But there were 4 records that should have been listed. so it should have shown another page and printed showing results 1 to 2 of 4.Any idea's. Thanks for all the help.
  3. reggie

    Listing Records

    I still cant work it out. I'll show you the whole code:This is the code for search.php <h3>Search Information:</h3><p><b>All Fields are Required to find Search Results. Try using the Advanced search to narrow your search results.</font></b><br><table><tr><td width="120">Looking For:</td><td><form name="form" action="searchresults.php" method="get"><select size="1" name="q1" tabindex="" class="form"><option value=""> </option><option value="agricultural">Agricultural</option><option value="business">Buisness</option><option value="building">Building Equipment / Material</option><option value="cosmetics">Cosmetics</option><option value="electrics">Electrics</option><option value="electronics">Electronics</option><option value="flying">Flying</option><option value="furniture">Furniture</option><option value="health">Health</option><option value="industrial">Industrial</option><option value="leisure">Leisure</option><option value="marine">Marine</option><option value="pets">Pets / Animals</option><option value="professional-tools">Professional Tools / Equipment</option><option value="projects">Projects</option><option value="property">Property</option><option value="services">Services</option><option value="sports">Sport</option><option value="travel">Travel</option><option value="vehicles">Vehicles</option><option value="misc">Misc</option></select></td></tr><tr><td width="120">Specify:</td><td><input size="20" name="q2" type="text" id="specify" tabindex="" class="form"></td></tr><tr><td width="120">To:</td><td><select size="1" name="q3" tabindex="" class="form"><option value=""> </option><option value="buy">Buy</option><option value="rent/hire">Rent / Hire</option><option value="share">Share Expenses</option></select></td></tr><tr><td><input type="submit" name="Submit" value="Search" /></td></form></tr></table> Then searchresults.php is what you gave me. Basically i want to list all records that are found with the criteria used from the search form q1,q2,q3 which are then passed to searchresults to $var1,$var2 and $var3. All i want is for the script to list the first 5 (for example) on one page and if any other records found to list them on the next page, and so on. I dont reallt know where 's' comes into it. i used this scripts from a free php site, and edited it. Im guessing s is the amount of records / results found...Hope this helps.....
  4. reggie

    Listing Records

    For some reason the new code only lists the limit. if the limit is 2 it only lists 2. even if it found 10. the next link doesnt appear...
  5. reggie

    Listing Records

    I have created a search form that allows members to search for other members with 3 search criteria's. I have created the script that searches the database for all records with these matches and lists them in order of username. I want the script to list say 3,5 or 10 matches per page with a link to the next set of matches etc....Any suggestions. I did use sopmething like thisecho " <a href=\"$PHP_SELF?s=$news&q1=$var1&q2=$var2&q3=$var3\">Next 10 >></a>";but the link repeat the same 5 matches over again.This is the script:<?php// Get the search variable from URL $var1 = @$_GET['q1'] ; $var2 = @$_GET['q2'] ; $var3 = @$_GET['q3'] ; $trimmed1 = trim($var1); //trim whitespace from the stored variable $trimmed2 = trim($var2); //trim whitespace from the stored variable $trimmed3 = trim($var3); //trim whitespace from the stored variable// rows to return$limit=2; // check for an empty string and display a message.if ($trimmed1 == "") { echo "<p>please enter a search</p>"; exit; }if ($trimmed2 == "") { echo "<p>please enter a search</p>"; exit; }if ($trimmed3 == "") { echo "<p>please enter a search</p>"; exit; }// check for a search parameterif (!isset($var1)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; }//connect to your database ** EDIT REQUIRED HERE **mysql_connect("localhost","root","admin"); //(host, username, password)//specify database ** EDIT REQUIRED HERE **mysql_select_db("db_loginarea") or die("Unable to select database"); //select which database we're using// Build SQL Query $query = "select * from users where lookingfor = '$trimmed1' and specify like '$trimmed2%' and buyrentshare = '$trimmed3' order by username"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults);if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p class='form'>Sorry, your search returned zero results</p>"; }// next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; }// get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query");// display what the person searched forecho "<p class='form'>Looking for - ".$var1."<br>Specified - ".$var2."<br>To - ".$var3."</p>";// now you can display the results returnedif ($numrows == 0){}else{// begin to show results set$count = 1 + $s ;echo "<table border='0' align='center' class='form' cellpadding='2' cellspacing='0'>"; echo "<tr>"; echo "<td bgcolor='lightgrey' width='200'><b>Username</b></td>"; echo "<td bgcolor='lightgrey' width='200'><b>Looking For</b></td>"; echo "<td bgcolor='lightgrey' width='200'><b>Specify</b></td>"; echo "<td bgcolor='lightgrey' width='200'><b>Country</b></td>"; echo "<td bgcolor='lightgrey' width='200'><b>Town / City</b></td>"; echo "</tr>"; while ($row= mysql_fetch_assoc($result)) { $user = $row["username"]; $title = $row["lookingfor"]; $specify = $row["specify"]; $budget = $row["budget"]; $to = $row["buyrentshare"]; $with = $row["withwho"]; $location = $row["countrylocated"]; $town = $row["towncity"]; echo "<tr>"; echo "<td>$user</td>"; echo "<td>$title</td>"; echo "<td>$specify</td>"; echo "<td>$location</td>"; echo "<td>$town</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'><b>view the profile of <a href=\"viewprofile.php?user=" . urlencode($row['username']) . "\">{$row['username']}</a></b></td>"; echo "</tr>"; echo "<tr>"; echo "<td height='10'></td>"; echo "</tr>"; $count++ ;}echo "</table>";$currPage = (($s/$limit) + 1);//break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a> "; }// calculate number of pages needing links $pages=intval($numrows/$limit);// $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; }// check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q1=$var1&q2=$var2&q3=$var3\">Next 10 >></a>"; }$a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p class='form'>Showing results $b to $a of $numrows</p>";} ?>
  6. I have created a members area and database that allows users to register etc.all works fine. Members can make a search for other members with certain criteria and view each members profile.Now im stuck....I want to produce an option for members to edit their own profile, some way of showing them their own info, which i know how to do. But not in an input field that they can then edit.All of my form inputs are in html and then uses php to enter data into table. And uses echo"<table>"; in php to view details.Can anyone help with this.
  7. I want to create a error message box that appears onces the user has clicked submit on a registration form. If the user doesnt fill in a filed to pop up an error message box and then once clicked ok to go back to the form.....I have used the javascript alert code, but i dont know how to open an error box in php and continue with the same form.Can anyone help.....
  8. reggie

    script doest work

    I have downloaded this free script, amended the database name ect....and it doest work. Doest anyone know why???<?php // Connects to your Database mysql_connect("localhost", "******", "********") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); //This code runs if the form has been submittedif (isset($_POST['submit'])) { //This makes sure they did not leave any fields blankif (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {die('You did not complete all of the required fields');}// checks if the username is in useif (!get_magic_quotes_gpc()) {$_POST['username'] = addslashes($_POST['username']);}$usercheck = $_POST['username'];$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error());$check2 = mysql_num_rows($check);//if the name exists it gives an errorif ($check2 != 0) {die('Sorry, the username '.$_POST['username'].' is already in use.');}// this makes sure both passwords entered matchif ($_POST['pass'] != $_POST['pass2']) {die('Your passwords did not match. ');}// here we encrypt the password and add slashes if needed$_POST['pass'] = md5($_POST['pass']);if (!get_magic_quotes_gpc()) {$_POST['pass'] = addslashes($_POST['pass']);$_POST['username'] = addslashes($_POST['username']);}// now we insert it into the database $insert = "INSERT INTO users (username, password)VALUES ('".$_POST['username']."', '".$_POST['pass']."')";$add_member = mysql_query($insert);?><!-- Now we let them know if their registration was successful --><h1>Registered</h1><p>Thank you, you have registered - you may now login</a>.</p><?php } else { ?><!-- This is what they see before they have registered --><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><table border="0"><tr><td>Username:</td><td><input type="text" name="username" maxlength="60"></td></tr><tr><td>Password:</td><td><input type="password" name="pass" maxlength="10"></td></tr><tr><td>Confirm Password:</td><td><input type="password" name="pass2" maxlength="10"></td></tr><tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table></form><?php } ?>
  9. reggie

    members script

    I have found a number of member / login scripts that use a post self method.For some reason they dont work. Doest anyone know of a free download that works, or could anyone help.I want a script that validates the registration and gives error messages within one file. The one i have that works t the moment loads a seperate .php file to validate and send error messages, but the error is on a blank screen. Also i would like to include a session or cookie to store username while logged in.Somehow included on each page a script that checks to see if each member is logged in or not.Something like thisFunction ValidateEntry{if error......else{include('welcomemember');session('user',$username);}<form>bla bla bla</form>------------------And on each other members pageIf session user != {error}Can anyone help...........
  10. Thank you vey much for that help...I have inserted the code you suggested and use this user id to search for the query and it all works fine.
  11. I think this is the problem...SELECT * FROM dictionary WHERE word LIKE '%" .If you only want to find a match that is exact to the search word you need to useWHERE word = $searchwordinstead of LIKE...This is used to find words like the word you search for....
  12. example....i have set up a table of users in mysql.i have put a search field to search for each member by usernamei have managed to produce the search and the display results which is done by using a while loopi want to be able to list each user by name and then a link next to each one. once the link is clicked a new page is loaded with the users profile listed.How do i establish with user they have selected from the table which is produced by a while loop.I cAN ONLY SEEM TO LIST THE LAST USER LISTED IN the while loop as the profile, no matter which one you select.Please can someone help.....
×
×
  • Create New...