Hi,
I am making a tutorial submit system where the input page submits the information into a mqsql database, then there is a page in which shows this information, however it isnt working correctly, if someone could please check my code and correct it, REP WILL BE GIVEN.
I have checked my best and cant see any php function spelling errors or the wrong formatting, will be greatful if you can help.
Thanks
Steven
This is the display tutorial Page
This is the data collection page:
Here is the process code:
And here is the mqsql table create code:
I am making a tutorial submit system where the input page submits the information into a mqsql database, then there is a page in which shows this information, however it isnt working correctly, if someone could please check my code and correct it, REP WILL BE GIVEN.
I have checked my best and cant see any php function spelling errors or the wrong formatting, will be greatful if you can help.
Thanks
Steven
This is the display tutorial Page
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
$connect = mysql_connect("localhost", "user", "password");
mysql_select_db("database", $connect);
$select = mysql_query("SELECT * FROM `tutorials`", $connect);
while($row = mysql_fetch_array($select, MYSQL_ASSOC)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$url = $row['url'];
$url2 = $row['url2'];
$WebsiteName = $row['WebsiteName '];
$TutorialName = $row['TutorialName'];
$description = $row['description'];
echo "
<p>
<strong>Tutorial Name:</strong> <a href="$url2;">$TutorialName</a><br />\n
<strong>Submitted By:</strong> <a href="$url;">$WebsiteName</a><br />\n
<strong>Description:</strong> $description
</p>
";
}
?>
</body>
</html>
This is the data collection page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<p>
<form action="process_data.php" method="post">
<input type="text" id="name" name="name" /> Name<br />
<input type="text" id="email" name="email" /> E-mail<br />
<input type="text" id="TutorialName" name="TutorialName" /> Tutorial Name<br />
<input type="text" id="WebsiteName" name="WebsiteName" /> Website Name<br />
<input type="text" id="url" name="url" value="http://" /> Website URL<br />
<input type="text" id="url2" name="url2" value="http://" /> Tutorial URL<br />
<textarea id="description" name="description" rows="5" cols="30"></textarea>Short Description<br />
<input type="submit" value="Submit" />
</form></p>
</body>
</html>
Here is the process code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$url2 = $_POST['url2'];
$description = $_POST['description'];
$TutorialName = $_POST['TutorialName'];
$WebsiteName = $_POST['WebsiteName'];
?>
<?php
require('functions.php');
$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$url = cleanUp($_POST['url']);
$url2 = cleanUp($_POST['url2']);
$description = cleanUp($_POST['description']);
$TutorialName = cleanUp($_POST['TutorialName']);
$WebsiteName = cleanUp($_POST['WebsiteName']);
if (empty($email)) {
echo "<p>Sorry, 'e-mail' is a required field. Please try again:</p>";
include('collect_data.php');
exit;
}
$connect = mysql_connect("localhost", "user", "password");
mysql_select_db("database", $connect);
$sql = "INSERT INTO `tutorials` VALUES ('', '$name', '$email', '$url', '$url2', '$TutorialName', '$WebsiteName', '$description')";
if (mysql_query($sql, $connect)) {
echo "Thank you $name, your Tutorial was inserted into the database.";
} else {
echo "Sorry $name, your tutorial could not be stored.";
}
?>
</body>
</html>
And here is the mqsql table create code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?
$connect = mysql_connect("localhost", "useer", "password");
mysql_select_db("database", $connect);
$create = "CREATE TABLE `tutorials` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 150 ) NOT NULL,
`email` VARCHAR( 255 ) NOT NULL,
`url` VARCHAR( 200 ) NOT NULL,
`url2` VARCHAR( 200 ) NOT NULL,
`description` TEXT NOT NULL,
`websitename` VARCHAR( 200 ) NOT NULL,
`tutorialname` VARCHAR( 200 ) NOT NULL,
PRIMARY KEY (`id`))";
if (mysql_query($create, $connect)) {
echo "Table (and fields) created.";
} else {
echo "Table (and fields) not created.";
}
?>
</body>
</html>
Last edited by a moderator:







