I need help with an assignment. I have been working of this the better part of a week and still do not really understand what I am meant to do. This is my first week using PHP and I am really confused. Here are the instructions:
Write a PHP script that obtains a URL and its description from a user and stores the information into a database using MySQL. Create and run a SQL script with a database named URL and a table named Urltable. The first field of the table should countain an actual URL, and the second, which is named Description, should contain a description of the URL. Use www.deitel.com as the first URL, and input Cool site! as its description. The second URL should be www.php.net, and the description should be The official PHP site. After each new URL is submitted, print the contents of the database in a table.
Also here are some added instructions from my proffesor.
The scripts of database for this chapter are attached here.
Please create a user account as the video in course materials to connect mySQL. We should use:
username: iw3htp
password: password
So the connection codes should be something like:
if ( !( $database = mysql_connect( "localhost", "iw3htp", "password" ) ) )
die( "<p>Could not connect to database</p>" );
I have the account and every thing it is just the code that is confusing me.
<!DOCTYPE html>
<html>
<head>
<meta charset ="utf-8";
<title>19.9</title>
</head>
<body>
<?php
if(!($database=mysql_connect("localhost","iw3htp","password")))
die("<p> Could not connect to database</p>");
$dbsel=@mysql_select_db("URl",$con);
if(!$dbsel)
die("error selecting database".mysql_error());
$ul=$_POST['ul'];
$de=$_POST['de'];
$q="insert into urltable values("$ul","$de")";
mysql_query($q);
$qw="select * from urltable";
$qwa=mysql_query($qw);
while($result =@mysql_fetch_array($qwa))
{
echo $result['urlname'];
echo $result['urldescription'];
}
?>
<form action="re.php" method="post">
url:<input type="text" name="ul"><br>
description:<input type="text" name="de">
<input type="submit" value="click here!">
</form>
</body>
</html>
Is this even close to being right? If it is could someone point me in the right direction of completing this assignment. If not I would love some help on making it right so that I am able to finish my assignment for the week.
Thanky you in advance.