I am trying to program a script for one of my site's. It is pretty easy I guess alot would say but I am a noob at php but I am trying to learn. Anyway I own growlinks.com and I am trying to make a list of directorys were users can add they link to to help get inbound links. And well I tried to make a form and it is not working. What do I want a is a form that ads the varible $url to the database. And on the other page I am displaying the links from the database so when someone adds on it will be listed. But I can't get the form to work. Here is some code:
Directory Name:<br>
<form action="adddir.php" method="post" >
<INPUT NAME="$url" TYPE="text" size="50"><br>
<input type="submit" name="$url" value="Add">
</form>
^is the form to add the link.
<?php
$url = $_REQUEST['$url'];
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
mysql_select_db("humorvid_directorys") or die(mysql_error());
// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1
(url) VALUES('$url')")
or die(mysql_error());
echo 'thanks';
^ is the php on adddir.php to handle the form input. But it is not adding the url to the database any ideas?
The below works and is the first attempt I made but I want a forum to do what the below does:
<?php
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
echo "Connected to MySQL";
mysql_select_db("humorvid_directorys") or die(mysql_error());
echo "Connected to Database";
$id= '1';
$id1='2';
$id2='3';
$url='http://www.01webdirectory.com';
$url1='http://www.abilogic.com';
$url2='http://www.agada.info/web-directory';
echo "Table Created!";
// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id', '$url')")
or die(mysql_error());
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id1', '$url1')")
or die(mysql_error());
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id2', '$url2')")
or die(mysql_error());
echo "Data Inserted!";
?>
Directory Name:<br>
<form action="adddir.php" method="post" >
<INPUT NAME="$url" TYPE="text" size="50"><br>
<input type="submit" name="$url" value="Add">
</form>
^is the form to add the link.
<?php
$url = $_REQUEST['$url'];
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
mysql_select_db("humorvid_directorys") or die(mysql_error());
// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1
(url) VALUES('$url')")
or die(mysql_error());
echo 'thanks';
^ is the php on adddir.php to handle the form input. But it is not adding the url to the database any ideas?
The below works and is the first attempt I made but I want a forum to do what the below does:
<?php
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
echo "Connected to MySQL";
mysql_select_db("humorvid_directorys") or die(mysql_error());
echo "Connected to Database";
$id= '1';
$id1='2';
$id2='3';
$url='http://www.01webdirectory.com';
$url1='http://www.abilogic.com';
$url2='http://www.agada.info/web-directory';
echo "Table Created!";
// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id', '$url')")
or die(mysql_error());
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id1', '$url1')")
or die(mysql_error());
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id2', '$url2')")
or die(mysql_error());
echo "Data Inserted!";
?>
Last edited:





