Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
OP Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
So you want to start using PHP/MySQL hu? I myself learn best looking through some basic code. I read tuts and texts and still barely knew what PHP was. Then Scallion/http://www.scallion.spoofed.net offered me a search engine he wrote for rrfn. I went through the code with a fine toothed comb.

I finally got it. It all came together and made perfect sense. Below I am posting the code scallion gave to rrfn. I have made many changes and add ons since this version. But this will help any PHP/MySQL newb out. It covers all the basics.

Take a look at the code and post any questions you have. Good luck. I would like to offer this as a download(the newest version) and maybe get a bit of open source with it. I am most intrested to see what you guys do different from what I did.


Code
 <?php
$password = "YOUR PASSWORD HERE";
$username = "YOUR USER NAME HERE";
$db = "YOUR DATABASE NAME HERE";
mysql_connect("localhost", $username, $password);
mysql_select_db($db);
if($cmd == "create") {
   $dg = mysql_query("CREATE TABLE ###IN THIS SPOT NAME OF YOUR TABLE FOR YOUR LINKS### (linkname VARCHAR(255), linkurl VARCHAR(255), kw1 VARCHAR(255), kw2 VARCHAR(255), kw3 VARCHAR(255), kw4 VARCHAR(255), kw5 VARCHAR(255), category INT,id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID))");  
     if($dg) echo "mySQL CREATE TABLE Worked Properly.
";
     else echo "mySQL Error: ".mysql_error();
     $dg = mysql_query("CREATE table ###NAME OF YOUR TABLE FOR CATEGORIES### (name VARCHAR(255), id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID))");
     if($dg) echo "mySQL CREATE TABLE Worked Properly.
";
     else echo "mySQL Error: ".mysql_error();
}
else if(!$cmd) {
   ?>
Search 

<form action="###NAME OF PHP FILE THIS SCRIPT IS IN###?cmd=search" method=POST>
Keyword: <font size=1>(Only one please)</font> 
<input type="text" name="keyword"> 
<input type="submit" value="Search">
</form>
<hr>
Browse 

<?
   $dg = mysql_query("SELECT * FROM NAME OF YOUR CATEGORY TABLE");
        while($dg2 = mysql_fetch_array($dg)) {
               echo "<a href=\"rrfn_links.php?cmd=browse&id=".$dg2['id']."\">".$dg2['name']."</a>
";
            }
}
else if($cmd == "admin") {
   ?>
Add Category 

<form action="rrfn_links.php?cmd=addcat" method=POST>
Category Name: <input type="text" name="catname"> 

Password: <input type="password" name="cpas"> 

<input type="submit" value="Add Category">
</form>
<hr>
Add Link 

<form action="rrfn_links.php?cmd=addlink" method=POST>
Password: <input type="password" name="cpas"> 

Link Name: <input type="text" name="lname"> 

Link URL: <input type="text" name="lurl"> 

Keywords <font size=1>(Up to 5 keywords, no spaces, separated by commas)</font>: <input type="text" name="kws"> 

Category: <select name="category">
<?
$cats = mysql_query("SELECT * FROM rrfn_cats");
while($cats2 = mysql_fetch_array($cats)) {
echo "<option value=\"".$cats2['id']."\">".$cats2['name'];
}
?>
</option>


<input type="submit" value="Add Link">
</form>
     <?
}
else if($cmd == "addcat") {
     if($cpas == "YOUR PASSWORD HERE") {
      $dg = mysql_query("INSERT INTO rrfn_cats (name) VALUES ('$catname')");
        if($dg) echo "mySQL INSERT Worked Properly.";
            else echo "mySQL Error: ".mysql_error();
             echo "<a href=\"./rrfn_links.php?cmd=admin\">
 back to the admin page</a>";
     }
     else { echo "Password didn't work out. Sorry."; }
}
else if($cmd == "addlink") {
     if($cpas == "YOUR PASSWORD HERE") {
      $keywords = split(",", $kws, 5);
        $dg = mysql_query("INSERT INTO rrfn_links (linkname, linkurl, kw1, kw2, kw3, kw4, kw5, category) VALUES ('$lname', '$lurl', '$keywords[1]', '$keywords[2]', '$keywords[3]', '$keywords[4]', '$keywords[0]', '$category')"); 
             if($dg) echo "mySQL INSERT Worked Properly.";
             else echo "mySQL Error: ".mysql_error();
             echo "<a href=\"./rrfn_links.php?cmd=admin\">
 back to the admin page</a>";
     }
     else { echo "Password didn't work out. Sorry."; }
}
else if($cmd == "browse") {
   echo "Results: 
";
   $dg = mysql_query("SELECT * FROM rrfn_links WHERE category='$id'");
     while($dg2 = mysql_fetch_array($dg)) {
        echo "<a href=\"".$dg2['linkurl']."\">".$dg2['linkname']."</a>
\n";
     }
}
else if($cmd == "search") {
   echo "Results: 
";
     $quer = "SELECT * FROM rrfn_links WHERE (kw1 LIKE '%$keyword%') OR (kw2 LIKE '%$keyword%') OR (kw3 LIKE '%$keyword%') OR (kw4 LIKE '%$keyword%') OR (kw5 LIKE '%$keyword%')";
     echo $quer."
";
     $dg = mysql_query($quer);
     if(mysql_num_rows($dg) == 0) { echo "No results found.  Sorry, try again. 
"; }
     else {
         while($dg2 = mysql_fetch_array($dg)) {
             echo "<a href=\"".$dg2['linkurl']."\">".$dg2['linkname']."</a>
\n";
             }
     } 
}
else if($cmd == "all") {
echo "<table border=1>";
?>
<tr>
<td>name
<td>url
<td>kw1
<td>kw2
<td>kw3
<td>kw4
<td>kw5
<td>category
<td>id#
<?
$result = mysql_query("SELECT * FROM rrfn_links");
while($myrow = mysql_fetch_row($result))
 {
 print " <tr> ";
  for($x=0; $x <= count($myrow); $x++)
  {
   print "<td>".$myrow[$x]."</td>";
  }
 print "</tr>";
}
echo "</table>";
}
?>  

Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
You should have bolded everything that they need to change :x...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
OP Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
&#91;b] and &#91;/b] do not work in side the code tags...

*shrugs*

Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Ahh ok heh...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
OP Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
No one is going to take up this challenge?


Link Copied to Clipboard
Member Spotlight
Phatal
Phatal
Houston, TX
Posts: 298
Joined: April 2004
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Cyrez 1
Girlie 1
unreal 1
Crime 1
Powered by UBB.threads™ PHP Forum Software 7.7.5