- Impact
- 3
Hi, this script was maid by poordoggy at this forum but something is wrong: the script is you fill out the forums and click submit if something is wrong it will just echo "something is wrong" but no matter what you put it sais it is always wrong. here is the script:
Im pretty possitive this is the problem:
i will send whoever fixes this problem all my np$ (witch isnt very much but its the best i can do)
<?php
// Lets start by adding some variables
$name = "";
$author = "";
$tutorial = "";
// Ok - lets find out if the user submitted the form
if( isset( $_POST['submit'] ) ) // if the submit button was pressed...
{
// change the variables...
$name = $_POST['name'];
$author = $_POST['author'];
$tutorial = $_POST['tutorial'];
if( !$_POST['name'] || !$_POST['author'] || !$_POST['tutorial'] ) // if anything was not filled in (|| = "or")
{
echo "There is a problem somewhere... please go down and check everything!";
}
else // if everything is ok...
{
// set your database infomation.
$dbhost='localhost'; // database host
$dbusername='mwise_form'; // username for db
$dbuserpass='hahaha'; // password for db
$dbname='mwise_form'; // database name
// connect to the mysql database server.
$connect = mysql_connect($dbhost, $dbusername, $dbuserpass);
// select the database
mysql_select_db($dbname);
// do the query
// I put the query into a variable this time
$sql = "INSERT INTO tutorials (name, author, tutorial) VALUES(".$name.", ".$author.", ".$tutorial.")";
if(mysql_query($sql))
{
echo "Added to database";
}
else
{
echo "something wrong";
}
}
}
?>
Im pretty possitive this is the problem:
if( !$_POST['name'] || !$_POST['author'] || !$_POST['tutorial'] ) // if anything was not filled in (|| = "or")
{
echo "There is a problem somewhere... please go down and check everything!";
}
i will send whoever fixes this problem all my np$ (witch isnt very much but its the best i can do)













