Jump to content

MDanz

Members
  • Posts

    728
  • Joined

  • Last visited

Everything posted by MDanz

  1. How do i do a simple report button to my email? e.g. $stack //is reply when the report button is pressed it sends an email with the stack variable.
  2. k i changed some stuff still not getting the results from database in drop down list.. <form action='added.php' method='post'> <select> <?php mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $sql=mysql_query("SELECT name FROM castack"); $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ $delete=$data['name']; echo $delete; } ?> </select> <input type='submit' name='delete' value='Delete' /> </form>
  3. sry i'll be clearer a drop down list with my results. And a delete button. this is what i attempted. But i'm not getting my results in the drop down list. <form action='added.php' method='post'> <select> <?php $sql='SELECT name FROM castack'; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ $delete=$data['name']; echo "$delete"; } ?> </select> <input type='submit' name='delete' value='Delete' /> </form> i'm quite new to php but i'm getting the hang of it
  4. <form action='delete.php' method='post'> <select> <?php $sql='SELECT name FROM castack'; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ echo $data['name']; } ?> </select> <input type='submit' name='delete' value='Delete' /> </form> i have a list/menu and they are supposed to display the all the results in the database. I select what one and i press the delete button. this isn't working its not displaying whats in the database.
  5. i'd like to check if the username is taken. ........if it is it echo's " bla bla choose another name" and also for email, so no duplicate email for users. how do i do this? here's the part of the code thats relevant echo "<h1>Register</h1>"; $submit = $_POST['submit']; $fullname = strip_tags($_POST['fullname']); $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); $email = $_POST['email']; $confirmpassword = strip_tags($_POST['confirmpassword']); $date = date("Y-m-d"); if($submit) { //check fields are filled if($fullname&&$username&&$password&&$confirmpassword) { if ($password==$confirmpassword) { //check character length of username and fullname if(strlen($username)>25||strlen($fullname)>25) { echo" Length of username or fullname is too long"; } else { //check password length if(strlen($password)>25||strlen($password)<6) { echo "Password must be between 6 and 25 characters"; } else { //register the user //encryt password $password = md5($password); $confirmpassword = md5($confirmpassword); //open database $connect =mysql_connect("localhost","Master","password"); mysql_select_db("Login"); //select database //generate random number for activation process $random = rand(23456789,98765432); $queryreg = mysql_query(" INSERT INTO Users VALUES ('','$fullname','$username','$password','$email','$date','$random','0','') "); $lastid = mysql_insert_id();
  6. $count = 0; echo "<table><tr>"; while($row = mysql_fetch_assoc($query)){ $username = $row['username']; $stackname = $row['name']; echo "<td>"; echo "<a href='http://www.sfdffasfs.com/search.php?search=$stackname' style='text-decoration: none';><table border='0' celpadding='0' cellspacing='0'> <tr> <td width='101px' height='101px' background='Stacks/template.jpg' VALIGN='middle'> <font color=black font size=3 font face=Arial><center><b>$stackname</b></center></font></td> </td> </tr> </table></a>"; echo "<td>"; if (($count % == 0){ echo "</tr><tr>"; } $count++; } } } k thx for help... i've implemented it into my code.. its displaying like this(L represents picture. L LL When i want it 8 column, then new row LLLLLLLL etc
  7. thx it worked how do i display all the results in a table and the limit is 8 columns. Once the results get to 8 columns then a new row is started?
  8. i've done this so far, but it only displays 1 row of the database. <?php session_start(); mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); if ($_SESSION['username']){ $query = mysql_query("SELECT * FROM castack"); if (mysql_num_rows($query)==0) die("Stack not found!"); else { $row = mysql_fetch_assoc($query); $username = $row['username']; $stackname = $row['name']; echo "<a href='http://www.nfjslnf.com/search.php?search=$stackname' style='text-decoration: none';><table border='0' celpadding='0' cellspacing='0'> <tr> <td width='101px' height='101px' background='Stacks/template.jpg' VALIGN='middle'> <font color=black font size=3 font face=Arial><center><b>$stackname</b></center></font></td> </td> </tr> </table></a>"; }} ?> i'd like it to display all the results in a table. and the limit is 8 columns. Once the results get to 8 columns then a new row is started.
  9. srry bad example.. e.g. http://www.example.com/reply.php?reply=Hello&submit=reply i want the 'Hello' part from the url
  10. echo 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; this gives me the url currently in my address bar. is there anyway to select a certain part of it. like it returns... www.example.com and i only want 'example'. ??
  11. hi thx for help.. returned the value '1' for some reason on search.php this is how i use $name & reply.php... <a href='http://www.example.com/reply.php?reply=$name&submit=reply'>Reply</a> so the reply is associated with the name of the result from the search. all the results have different names, so when a user replies, it uses the name(result) like a thread title. and in reply.php this is the text field i want the $name value in. I tried it this way originally then your way. <input type='text' name='keywords' value='$name' <br>
  12. I have a search engine.. when the results come... i want to post the $name variable from the result to reply.php this is how i show results echo '<table '.$margin.'>'; while ($runrows = mysql_fetch_assoc($run)){ $id = $runrows['id']; $name = $runrows['name']; $image = $runrows['image']; $hyperlink = $runrows['hyperlink']; $currency = $runrows['currency']; $info = $runrows['info']; $type = $runrows['type']; $rating = $runrows['rating']; $keywords = $runrows['keywords']; echo '<td><tr>'; echo "<a href='$hyperlink'><img src='http://www.u-stack.com/Stack.jpg'></a>"; echo "</tr><font color=white><strong> $name - $info - $rating <a href='rate.php?id=$id'><img src='http://www.u-stack.com/rate.jpg'></a></font> <a href='http://www.u-stack.com/reply.php?reply=$name&submit=reply' style='text-decoration: none'; >Reply</a> </center><br><br><hr size='1'></strong></td>"; } echo '</table>'; i want to post the $name variable to reply.php so in the reply.php textfield, i can set the value as $name and the name of the result appears in the textfield.
  13. i did that now search not working, just blank page??
  14. where do i place it/ implement it?
  15. i have this form <form action="search.php" method="get"> <center> <input name="search" type="text" value="" size="25" /> <input type="submit" name="submit" value="search"> </center> </form> i want only text and numbers to be input .... no html how to do this?
  16. <?php mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $button = $_GET['submit']; $search = $_GET['search']; if(!$search){ echo "<br>You didn't submit a keyword"; }else{ if(!isset($search) || strlen($search)<=2){ echo "<br><font color=white><br>search term too short</font>"; }else{ echo "<br><br><font color=white><br>you searched for <b>$search</b></font><hr size='1'>"; } //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each){ //construct query $x++; if($x==1){ $construct .= " `keywords` LIKE '%" . mysql_real_escape_string($search_each) . "%'"; }else{ $construct .= " OR `keywords` LIKE '%" . mysql_real_escape_string($search_each) . "%'"; } $construct = "SELECT * FROM `Stacks` WHERE $construct"; } // How many items to show per page $limit = 10; $page = $_GET['page']; if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } $foundnum = mysql_num_rows(mysql_query($construct)); $construct = $construct.' LIMIT '.$start.' , '.$limit; $run = mysql_query($construct); echo mysql_error(); if ($foundnum==0){ echo "<br><br><font color=white>No Stacks Found</font>"; }else{ echo "<font color=white>$foundnum <img src='http://www.u-stack.com/mini%20stack.jpg'> Found!</font><hr size='1'><p>"; echo '<table '.$margin.'>'; while ($runrows = mysql_fetch_assoc($run)){ $id = $runrows['id']; $name = $runrows['name']; $image = $runrows['image']; $hyperlink = $runrows['hyperlink']; $currency = $runrows['currency']; $info = $runrows['info']; $type = $runrows['type']; $rating = $runrows['rating']; $keywords = $runrows['keywords']; echo '<td><tr>'; echo "<a href='$hyperlink'><img src='http://www.u-stack.com/Stack.jpg'></a>"; echo "</tr><font color=white><strong> $name - $info - $rating <a href='rate.php?id=$id'><img src='http://www.u-stack.com/rate.jpg'></a></font> <a href='http://www.u-stack.com/reply.php?reply=$name&submit=reply' style='text-decoration: none'; >Reply</a> </center><br><br><hr size='1'></strong></td>"; } echo '</table>'; } // How many adjacent pages should be shown on each side? $adjacents = 3; // Your file name (the name of this file) $targetpage = "search.php"; if ($page == 0){ $page = 1; } $prev = $page - 1; $next = $page + 1; $lastpage = ceil($foundnum/$limit); $lpm1 = $lastpage - 1; $pagination = ""; if($lastpage > 1){ $pagination .= "<div class=\"pagination\">"; // Previous if ($page > 1){ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$prev\">« previous</a>"; }else{ $pagination .= "<span class=\"disabled\">« previous</span>"; } // Pages if ($lastpage < (7 + ($adjacents * 2))){ for ($counter = 1; $counter <= $lastpage; $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$counter\">$counter</a>"; } } }elseif($lastpage > (5 + ($adjacents * 2))){ if($page < 1 + ($adjacents * 2)){ for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$counter\">$counter</a>"; } } } $pagination .= "..."; $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$lpm1\">$lpm1</a>"; $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$lastpage\">$lastpage</a>"; }elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)){ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=1\">1</a>"; $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=2\">2</a>"; $pagination .= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$counter\">$counter</a>"; } } $pagination .= "..."; $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$lpm1\">$lpm1</a>"; $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$lastpage\">$lastpage</a>"; }else{ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=1\">1</a>"; $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=2\">2</a>"; $pagination .= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$counter\">$counter</a>"; } } } // Next if ($page < $counter - 1){ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&page=$next\">next »</a>"; }else{ $pagination .= "<span class=\"disabled\">next »</span>"; $pagination .= "</div>\n"; } } echo $pagination; } ?> only happens when i've typed more than one word in the search bar.
  17. when i search for one word, everything is fine... when i search for two i get this error it's coming from this part of the code whats wrong?
  18. hi, i've tried e.g. www.example.com/stack.php?id=1 in address bar . this is the upload page <?php session_start(); if ($_SESSION['username']){ $stacks= " <font color=white>Welcome, ".$_SESSION['username']."!<br><a href='Logout.php'>Log Out</a></font> <form enctype='multipart/form-data' action='insert3.php' method='post' name='changer'> <p align='center'> <input name='name' value='name' type='text'> <br> <input type='submit' name='submit' value='Submit'><br></p></form>"; echo "$stacks"; } ?> how can i implement your code into this. I want it before the if statement. So in the address bar i can type e.g. www.example.com/stack.php?id=1 and get row 1 from my table.
  19. i have the page.. stack.php I've done the database mysql fields, name and id I've done the upload page... it uploads a name and id to mysql i've uploaded two records... how do i get stack.php to display only id 1 ? e.g. www.example.com/stack.php?id=1 So i can use stack.php as a template and have multiple pages, with id represent the data shown on that page. any help really appreciated.
  20. i have no idea what xss are? how do i go about preventing them? are they easy to implement into my code?
  21. mysql_select_db ($database); // Make sure the user actually // selected and uploaded a file $hyperlink = $_POST['hyperlink']; $currency = $_POST['currency']; $name = $_POST['name']; $image = $_POST['image']; $info = $_POST['info']; $keywords = $_POST['keywords']; $type = $_POST['type']; // Create the query and insert // into our database. $query = "INSERT INTO Stacks"; $query .= "(`image`, `hyperlink`,`currency`,`name`,`info`,`keywords`,`type`) VALUES ('$image','$hyperlink','$currency','$name','$info','$keywords','$type')"; $results = mysql_query($query, $link); if($query){ print "<br><font color=white>Your image details have been uploaded to the database. <a href='member.php'>Return to Upload Page</a></font>"; } else { print "No image selected/uploaded"; } // Close our MySQL Link mysql_close($link); how/where do i add mysql_real_escape_string to this to prevent html attack?
  22. I have a table in mysql. with an id, title, description, image and link. The aim is to have 1 template page and according to the id, it changes on the row chosen. so e.g. http://localhost/template.php?id=4 i was doing it like this..this is the code to generate the links <?php echo "<a href= 'stack.php?title=" . urlencode( $title ) . "&description=". urlencode( $description ) . "&image=" .urlencode( $image ) . "'>Create A Stack</a>";?> this is the template php <?php $title = urldecode( $_GET['title'] ); $description = urldecode( $_GET['description'] ); $image = urldecode( $_GET['image'] ); echo "<h1>" . $title . "</h1>"; echo "<img src='" . $image . "'>"; echo "<p>" . $description . "</p>"; ?> how do i change this so i would only pass one unique id through the URL. i changed this.. how do i change the template php though? <?php echo "<a href= 'stack.php?id=" . urlencode( $id ). "'>Create A Stack</a>";?>
  23. you can check my website for an example... http://www.u-stack.com/search.php?search=basketball&submit=search when you you go to next.. everything is fine.. then go back to previous, the results are different? :'( <?php mysql_connect("localhost", "Master", "password"); mysql_select_db("Ustack"); $button = $_GET['submit']; $search = $_GET['search']; if(!$button){ echo "<br>You didn't submit a keyword"; }else{ if(!isset($search) || strlen($search)<=2){ echo "<br><font color=white><br>search term too short</font>"; }else{ echo "<br><br><font color=white><br>you searched for <b>$search</b></font><hr size='1'>"; } //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each){ //construct query $x++; if($x==1){ $construct .= " `keywords` LIKE '%$search_each%'"; }else{ // these both need spaces. $construct .= " OR `keywords` LIKE '%$search_each%'"; } $construct = "SELECT * FROM `Stacks` WHERE $construct"; } // How many items to show per page $limit = 5; $page = $_GET['page']; if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } $construct = $construct.' LIMIT '.$start.' , '.$limit; $run = mysql_query($construct); $foundnum = mysql_num_rows(mysql_query('SELECT * FROM `Stacks`')); echo mysql_error(); if ($foundnum==0){ echo "<br><br><font color=white>No Stacks Found</font>"; }else{ echo "<font color=white>$foundnum <img src='http://www.u-stack.com/mini%20stack.jpg'> Found!</font><hr size='1'><p>"; echo '<table '.$margin.'>'; //here you do your loop like while ($runrows = mysql_fetch_assoc($run)){ //get data <== all thi is very not needed. $id = $runrows['id']; $name = $runrows['name']; $image = $runrows['image']; $hyperlink = $runrows['hyperlink']; $currency = $runrows['currency']; $info = $runrows['info']; $type = $runrows['type']; $rating = $runrows['rating']; echo '<td><tr>'; echo "<a href='$hyperlink'><img src='http://www.u-stack.com/Stack.jpg'></a>"; echo "</tr><font color=white><strong> $name - $info - $rating <a href='rate.php?id=$id'><img src='http://www.u-stack.com/rate.jpg'></a></center><br><br><hr size='1'></strong></font></td>"; } echo '</table>'; } // How many adjacent pages should be shown on each side? $adjacents = 3; // Your file name (the name of this file) $targetpage = "search.php"; if ($page == 0){ $page = 1; } $prev = $page - 1; $next = $page + 1; $lastpage = ceil($foundnum/$limit); $lpm1 = $lastpage - 1; $pagination = ""; if($lastpage > 1){ $pagination .= "<div class=\"pagination\">"; // Previous if ($page > 1){ $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$prev\">« previous</a>"; }else{ $pagination .= "<span class=\"disabled\">« previous</span>"; } // Pages if ($lastpage < (7 + ($adjacents * 2))){ for ($counter = 1; $counter <= $lastpage; $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$counter\">$counter</a>"; } } }elseif($lastpage > (5 + ($adjacents * 2))){ if($page < 1 + ($adjacents * 2)){ for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$counter\">$counter</a>"; } } } } $pagination .= "..."; $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$lpm1\">$lpm1</a>"; $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$lastpage\">$lastpage</a>"; }elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)){ $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=1\">1</a>"; $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=2\">2</a>"; $pagination .= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$counter\">$counter</a>"; } } $pagination .= "..."; $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$lpm1\">$lpm1</a>"; $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=$lastpage\">$lastpage</a>"; }else{ $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=1\">1</a>"; $pagination .= "<a href=\"$targetpage?$targetpage?search=".$_GET['search']."&submit=search&page=2\">2</a>"; $pagination .= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++){ if ($counter == $page){ $pagination .= "<span class=\"current\">$counter</span>"; }else{ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&submit=search&page=$counter\">$counter</a>"; } } } // Next if ($page < $counter - 1){ $pagination .= "<a href=\"$targetpage?search=".$_GET['search']."&submit=search&page=$next\">next »</a>"; }else{ $pagination .= "<span class=\"disabled\">next »</span>"; $pagination .= "</div>\n"; } echo $pagination; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.