Jump to content

Recommended Posts

on my registration form, i have a few things that are required , how can i have it so that it shows the error on next to the form and keeps what the user entered in the form(except password). My form is embebed into a page, so i cannont include the page, as it will shows the begging on the page and not the registration form.

this is my part of code

if(isset($_POST['admin_signup'])){	
require_once '../includes/db_connect.php';
$user_name = mysql_real_escape_string($_POST["user_name"]);		
$user_password =mysql_real_escape_string($_POST["user_password"]);		
$user_password2 =mysql_real_escape_string ($_POST["user_password2"]);
$user_email =mysql_real_escape_string ($_POST["user_email"]);		
$user_email2 =mysql_real_escape_string ($_POST["user_email2"]);
$ip = $_SERVER['REMOTE_ADDR'];
if ($user_name && $user_password && $user_password2 && $user_email && $user_email2)
{
	$user_check = mysql_num_rows(mysql_query("SELECT * FROM `$user` WHERE userlevel=1 "));	
$length = strlen($user_password);
if ($length >= 6)
{
if ($user_check >= 1)	
{
	echo "Sorry, but the head admin account is already created. Please delete the table in your mysql database and run the install.php file.";
}
elseif ($user_password == $user_password2 && $user_email == $user_email2)
{
$userPswd = md5($user_password);
$userpwsd = sha1($userPswd);
mysql_query("INSERT INTO `$user` (user_id,  user_name, user_password, user_email, user_ip, userlevel) VALUES ('','$user_name','$userpwsd','$user_email','$ip','1')")
or die('Error ' . mysql_error());
require_once 'main_write.php';
require_once 'redirect_install.php';
 }
 }
else
{
echo "Either the passwords or emails you entered do not match. Please check these details and try again";	

}
} 

else 
{
echo "Please fill in all of the required fields.";
mysql_close();
}
}
exit();
?>
<?php
if(isset($_POST['continue_saved']))
{
require_once '../includes/db_connect.php';
?>
<html>
<table bgcolor='#999999' align='center' width="400px">
<form action='<?php $_SERVER['PHP_SELF']; ?>' method='POST'>
<tr><td width="10px">Username: </td><td><input type='text' name='user_name' maxlength="20" width="400px"  /><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">E-mail Address:</td> <td><input type='text' name='user_email' /><br /></td></tr>
<tr><td width="10px">Confirm E-mail Address: </td><td><input type='text' name='user_email2'/><br /></td></tr>
<tr><td width="10px">Password:</td><td> <input type='password' name='user_password' maxlength="30"/><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">Confirm Password:</td><td> <input type='password' name='user_password2'  maxlength="30" /><br /></td></tr>
<tr><td><input type='submit' value='Complete Registration' name='admin_signup' /></td><td><input type="reset" value="Reset Fields" name="reset" /></td></tr>
</form>
</table>
</html>
<?php
exit();
}

Link to comment
https://forums.phpfreaks.com/topic/104483-how-to-keep-data-in-a-form/
Share on other sites

ok, thanks for the reply, i didn't think of trying that.

Here is an update of my code, does anyone know how to echo the error on next to the form without inlcuding the file?

 

<?php
// Random Game Design: PHP Website Template
//  Version 1
//  Copyright Dean Whitehouse, 2008
if(isset($_POST['admin_signup'])){	
require_once '../includes/db_connect.php';
$user_name = mysql_real_escape_string($_POST["user_name"]);		
$user_password =mysql_real_escape_string($_POST["user_password"]);		
$user_password2 =mysql_real_escape_string ($_POST["user_password2"]);
$user_email =mysql_real_escape_string ($_POST["user_email"]);		
$user_email2 =mysql_real_escape_string ($_POST["user_email2"]);
$ip = $_SERVER['REMOTE_ADDR'];
$checkpw = $user_password == $user_password2;
$checkem = $user_email == $user_email2;
if ($user_name && $user_password && $user_password2 && $user_email && $user_email2)
	{
		$user_check = mysql_num_rows(mysql_query("SELECT * FROM $user WHERE user_email='$user_email' 
																			OR user_name='$user_name'"));
			$length = strlen($user_password);
			$length1 = strlen($user_name);
				if ($length >= 6)
				{
					if ($length1 >= 4)
					{
						if ($user_check >= 1)
						{
							require_once 'register.php';
							echo "Sorry, but the username or email you
							 requested is already in use. Please enter a different username.";
						}

							elseif ($user_password == $user_password2 && $user_email == $user_email2)
							{
							$userPswd = md5($user_password);
							$userpwsd = sha1($userPswd);
							mysql_query("INSERT INTO `$user` (user_id, 
							 user_name, user_password, user_email, user_ip, userlevel
							 ) VALUES 		('','$user_name','$userpwsd','$user_email','$ip','1')")
							or die('Error ' . mysql_error());
							echo "Succesfully Registered.";
							header ("http://".$_SERVER[HTTP_HOST]);
 							}
					}
				}



						if($length <= 5)
						{

							echo "Password Too Short<br>";
						}

					if($length1 <= 3)
					{

						echo "Username Too Short.<br>";
					}

				if(!$checkpw)
				{

						echo "The passwords you entered do not match. Please check these details and try again.<br>";
				}

			if(!$checkem)
			{
				echo "The emails you entered do not match. Please check these details and try again.<br>";
			}
	}
	else 
		{

			echo "Please fill in all of the required fields.";
		}
mysql_close();
}
exit();
if(isset($_POST['continue_saved']))
{
require_once '../includes/db_connect.php';
?>
<html>
<table bgcolor='#999999' align='center' width="400px">
<form action='<?php $_SERVER['PHP_SELF']; ?>' method='POST'>
<tr><td width="10px">Username: </td><td><input type='text' name='user_name' maxlength="20" width="400px" value="<?php echo $user_name ?>" /><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">E-mail Address:</td> <td><input type='text' name='user_email' value="<?php echo $user_email ?>"/><br /></td></tr>
<tr><td width="10px">Confirm E-mail Address: </td><td><input type='text' name='user_email2' value="<?php echo $user_email2 ?>"/><br /></td></tr>
<tr><td width="10px">Password:</td><td> <input type='password' name='user_password' maxlength="30"/><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">Confirm Password:</td><td> <input type='password' name='user_password2'  maxlength="30" /><br /></td></tr>
<tr><td><input type='submit' value='Complete Registration' name='admin_signup' /></td><td><input type="reset" value="Reset Fields" name="reset" /></td></tr>
</form>
</table>
</html>
<?php
exit();
}

For every error generated you should be appending it to a string.  This would allow you to echo the string out next to the form.  Ex:

 

<?php
$error_string = '';

$length = strlen($user_password);
			$length1 = strlen($user_name);
				if ($length >= 6) {
					if ($length1 >= 4) {
						if ($user_check >= 1) {
							require_once 'register.php';
							$error_string .= "Sorry, but the username or email you
							 requested is already in use. Please enter a different username.<br/>";
						}

......

<html>
<table bgcolor='#999999' align='center' width="400px">
<?php if (isset($error_string) && $error_string != '') echo $error_string; ?>

 

I would also recommend you format your errors in a slightly more conventional way such as an unordered list.

 

<ul>
  <li>error 1</li>
  <li>error 2</li>
  ...
<ul>

ok, i have another related problem(related to this script)

it's hard to explain, but i will try, the first table in the script should only appear once, and then not again (so only if you run the page, and then when you press next(or what ever) you don't see it) but it appears on every part of the installation.

here is my script

<?php
// Random Game Design: PHP Website Template
//  Version 1
//  Copyright Dean Whitehouse, 2008
session_start();
?>

<!------------------------------------------------------------------------------------------------------->
<table align='center' bgcolor="#999999" width='300px' border='0'><form method='post' action="<?php $_SERVER['PHP_SELF']; ?>">
<tr><td>
Database Host:</td><td>  
<input type='text' name='dbhost' onClick="this.value=''" value="Database Host"><br></td></tr>
<tr><td>
Database Username:</td><td>  
<input type='text' name='dbuser' onClick="this.value=''" value="Database Username"><br></td></tr>
<tr><td>
Database Password:  </td><td>
<input type='text' name='dbpass' onClick="this.value=''" value="Database Password"><br></td></tr>
<tr><td>
Database Name:  </td><td>
<input type='text' name='dbname' onClick="this.value=''" value="Database Name"><br></td></tr>
<tr><td></td><td><input type='submit' value='Continue' name='check'>
</td></tr></form>
</table>

<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['check']))
{
// Database Connection Information
$dbhost = $_POST["dbhost"];			// Database Host
$dbuser = $_POST["dbuser"];		// Database Username
$dbpass = $_POST["dbpass"];		// Database Password
$dbname = $_POST["dbname"];			// Database Name


// Attempt to connect to the database using the user submitted form.
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if ($con)
{
require_once 'config_write.php';
echo "You have successfully connected with these details to '$dbname'. <br>Username - '$dbuser'<br> Password - '$dbpass'<br> Database Host - '$dbhost'<br>Please enter the table names you want, or if you want to use the preset names click continue. NOTE: Each table must be a different name. Please do not leave any blank spaces.
";
?>
<table align="center" bgcolor="#333333" width="300px" border="0">
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<tr><td><font color="#FFFFFF">User Details:</td><td><input type='text' name='user' onClick="this.value=''" value="Users"></td></tr>
<tr><td><font color="#ffffff">Forum Questions</td>
<td><input type="text" name='forum_question' onClick="this.value=''" value="questions"></td></tr>
<tr><td><font color='#ffffff'>Forum Answers</td>
<td><input type='text' name='forum_answers' onClick="this.value=''" value="answers"><br></td></tr>
<tr><td></td><td><input type='submit' value='Continue' name='table_names'></td></tr>
</font>
</form>
</table>	
<?php 
}					
else
{
	echo 'Error connecting to database:'  . mysql_error() . '\n';		// Database creation failed
}
// Close connection to the database
mysql_close();
}
?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['table_names']))
{
require_once '../includes/db_connect.php';
$dbhost = $_POST["dbhost"];			
$user = $_POST["user"];
$forum_quest = $_POST["forum_question"];
$forum_answ = $_POST ["forum_answers"];
if ($user.$forum_quest.$forum_answ)
{
require_once "config_writetable.php";
echo "Table details saved:<br>User details saved: $user<br>Forum Questions saved: $forum_quest<br>Forum Answers saved: $forum_answ";
?>
<p>Table name's saved, press continue to create the table.<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<input type='submit' value='Continue' name='table_saved'>
</form>
</p>
<?php
}
else
{
echo ("Please go back and fill in the required fields");
}
}
?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['table_saved']))
{
require_once '../includes/db_connect.php';
mysql_connect($dbhost,$dbuser,$dbpass)
or die('Could not connect: ' . mysql_error());

// Select database
mysql_select_db($dbname)
or die('Could not find the database: ' . mysql_error());

$sql_user = "CREATE TABLE $user(
user_id int(11) AUTO_INCREMENT NOT NULL PRIMARY KEY,
user_name varchar(100) NOT NULL,
user_password varchar(100) NOT NULL,
user_email varchar(100) NOT NULL,
user_ip varchar(20) NOT NULL,
user_ban varchar(3) NOT NULL,
ban_reason varchar(100) NOT NULL,
ban_length varchar(25) NOT NULL,
userlevel tinyint(1) unsigned NOT NULL,
random_key varchar(32) NOT NULL,
user_activated varchar(25) NOT NULL,
show_email int(1) NOT NULL
)";


$sql_forum1 = "CREATE TABLE $forum_quest(
id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
topic varchar(255) NOT NULL default '',
detail longtext NOT NULL,
name varchar(65) NOT NULL default '',
email varchar(65) NOT NULL default '',
datetime varchar(25) NOT NULL default '',
view int(4) NOT NULL default '0',
reply int(4) NOT NULL default '0'
)";


$sql_forum2 = "CREATE TABLE $forum_answ(
question_id int(4) NOT NULL default '0' PRIMARY KEY,
a_id int(4) NOT NULL default '0',
a_name varchar(65) NOT NULL default '',
a_email varchar(65) NOT NULL default '',
a_answer longtext NOT NULL,
a_datetime varchar(25) NOT NULL default '',
)";

$make_user= mysql_query($sql_user);
$make_forum = mysql_query($sql_forum1);
$make_forum1 = mysql_query($sql_forum2);
$checkifexist_user = mysql_query ("SELECT * FROM '$user' LIMIT 0,1");
$checkifexist_quest = mysql_query ("SELECT * FROM '$forum_quest' LIMIT 0,1");
$checkifexist_answ = mysql_query ("SELECT * FROM '$forum_answ' LIMIT 0,1");

if (!$make_user)
{
echo("'$user' Table already exists.<br>'$user' table could not be created.<br>");
}
else
{
echo("'$user' Table Created.<br>");
}
if (!make_forum)
{
echo("'$forum_quest' Table already exists.<br>'$forum_quest' table could not be created.<br>");
}
else
{
echo("'$forum_quest' Table Created.<br>");
}
if (!make_forum1)
{
echo("'$forum_quest' Table already exists.<br>'$forum_quest' table could not be created.<br>");
}
else
{
echo("'$forum_answ' Table Created.<br>");
}
?><form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<input type="submit" value="Continue" name="continue_saved"/>
<?
mysql_close();
exit();
}
?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['continue_saved']))
{
require_once '../includes/db_connect.php';
?>
<html>
<table bgcolor='#999999' align='center' width="400px">
<form action='<?php $_SERVER['PHP_SELF']; ?>' method='POST'>
<tr><td width="10px">Username: </td><td><input type='text' name='user_name' maxlength="20" width="400px"  /><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">E-mail Address:</td> <td><input type='text' name='user_email' /><br /></td></tr>
<tr><td width="10px">Confirm E-mail Address: </td><td><input type='text' name='user_email2'/><br /></td></tr>
<tr><td width="10px">Password:</td><td> <input type='password' name='user_password' maxlength="30"/><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">Confirm Password:</td><td> <input type='password' name='user_password2'  maxlength="30" /><br /></td></tr>
<tr><td><input type='submit' value='Complete Registration' name='admin_signup' /></td><td><input type="reset" value="Reset Fields" name="reset" /></td></tr>
</form>
</table>
</html>
<?php
}
?>
<!------------------------------------------------------------------------------------------------------->
<?php //admin form ?>
<?php
if(isset($_POST['admin_signup'])){	
require_once '../includes/db_connect.php';
$user_name = mysql_real_escape_string($_POST["user_name"]);		
$user_password =mysql_real_escape_string($_POST["user_password"]);		
$user_password2 =mysql_real_escape_string ($_POST["user_password2"]);
$user_email =mysql_real_escape_string ($_POST["user_email"]);		
$user_email2 =mysql_real_escape_string ($_POST["user_email2"]);
$ip = $_SERVER['REMOTE_ADDR'];
$checkpw = $user_password == $user_password2;
$checkem = $user_email == $user_email2;
if ($user_name && $user_password && $user_password2 && $user_email && $user_email2)
{
		$user_check = mysql_num_rows(mysql_query("SELECT * FROM `$user` WHERE userlevel=1 "));	
		$length = strlen($user_password);
		$length1 = strlen($user_name);
		if ($length >= 6)
				{
					if ($length1 >= 4)
					{
						if ($user_check >= 1)
						{
							echo "Sorry, but the head admin account is already created. Please delete the table in your mysql 		                                database and run the install.php file.";
						}
							elseif ($checkpw.$checkem)
							{
							$userPswd = md5($user_password);
							$userpwsd = sha1($userPswd);
							mysql_query("INSERT INTO `$user` (user_id,  user_name, user_password, user_email, user_ip, userlevel) VALUES ('','$user_name','$userpwsd','$user_email','$ip','1')")
							or die('Error ' . mysql_error());
						require_once 'main_write.php';
						require_once 'redirect_install.php';
							 }
					 }
				} 
						if($length <= 5)
						{

							echo "Password Too Short<br>";
						}

					if($length1 <= 3)
					{

						echo "Username Too Short.<br>";
					}

				if(!$checkpw)
				{

						echo "The passwords you entered do not match. Please check these details and try again.<br>";
				}

			if(!$checkem)
			{

				echo "The emails you entered do not match. Please check these details and try again.<br>";
			}
	}
	else 
		{

			echo "Please fill in all of the required fields.";
		}
mysql_close();			
}

?>
<!------------------------------------------------------------------------------------------------------->

 

each part of the installation is seperated by html comment tags

yer, but i have a quick fix solution.

this is what i am using now

<?php
// Random Game Design: PHP Website Template
//  Version 1
//  Copyright Dean Whitehouse, 2008
?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['table_names']))
{
require_once '../includes/db_connect.php';
$dbhost = $_POST["dbhost"];			
$user = $_POST["user"];
$forum_quest = $_POST["forum_question"];
$forum_answ = $_POST ["forum_answers"];
if ($user.$forum_quest.$forum_answ)
{
require_once "config_writetable.php";
echo "Table details saved:<br>User details saved: $user<br>Forum Questions saved: $forum_quest<br>Forum Answers saved: $forum_answ";
?>
<p>Table name's saved, press continue to create the table.<form action="<?php $_SERVER['PHP_SELF'] ?>?stage3" method="post">
<input type='submit' value='Continue' name='table_saved'>
</form>
</p>
<?php
}
else
{
echo ("Please go back and fill in the required fields");
}
mysql_close();
exit();
}

?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['table_saved']))
{
require_once '../includes/db_connect.php';
require_once '../includes/config_table.inc.php';
mysql_connect($dbhost,$dbuser,$dbpass)
or die('Could not connect: ' . mysql_error());

// Select database
mysql_select_db($dbname)
or die('Could not find the database: ' . mysql_error());

$sql_user = "CREATE TABLE $user(
user_id int(11) AUTO_INCREMENT NOT NULL PRIMARY KEY,
user_name varchar(100) NOT NULL,
user_password varchar(100) NOT NULL,
user_email varchar(100) NOT NULL,
user_ip varchar(20) NOT NULL,
user_ban varchar(3) NOT NULL,
ban_reason varchar(100) NOT NULL,
ban_length varchar(25) NOT NULL,
userlevel tinyint(1) unsigned NOT NULL,
random_key varchar(32) NOT NULL,
user_activated varchar(25) NOT NULL,
show_email int(1) NOT NULL
)";


$sql_forum1 = "CREATE TABLE $forum_quest(
id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
topic varchar(255) NOT NULL default '',
detail longtext NOT NULL,
name varchar(65) NOT NULL default '',
email varchar(65) NOT NULL default '',
datetime varchar(25) NOT NULL default '',
view int(4) NOT NULL default '0',
reply int(4) NOT NULL default '0'
)";


$sql_forum2 = "CREATE TABLE $forum_answ(
question_id int(4) NOT NULL default '0',
a_id int(4) NOT NULL default '0',
a_name varchar(65) NOT NULL default '',
a_email varchar(65) NOT NULL default '',
a_answer longtext NOT NULL,
a_datetime varchar(25) NOT NULL default '',
KEY a_id (`a_id`)
)";

$make_user= mysql_query($sql_user);
$make_forum = mysql_query($sql_forum1);
$make_forum1 = mysql_query($sql_forum2);
$checkifexist_user = mysql_query ("SELECT * FROM '$user' LIMIT 0,1");
$checkifexist_quest = mysql_query ("SELECT * FROM '$forum_quest' LIMIT 0,1");
$checkifexist_answ = mysql_query ("SELECT * FROM '$forum_answ' LIMIT 0,1");

if (!$make_user)
{
echo("'$user' Table already exists.<br>'$user' table could not be created.<br>");
}
else
{
echo("'$user' Table Created.<br>");
}
if (!make_forum)
{
echo("'$forum_quest' Table already exists.<br>'$forum_quest' table could not be created.<br>");
}
else
{
echo("'$forum_quest' Table Created.<br>");
}
if (!make_forum1)
{
echo("'$forum_quest' Table already exists.<br>'$forum_quest' table could not be created.<br>");
}
else
{
echo("'$forum_answ' Table Created.<br>");
}
?><form action="<?php $_SERVER['PHP_SELF'] ?>?stage4" method="post">
<input type="submit" value="Continue" name="continue_saved"/>
<?
mysql_close();
exit();
}
?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['continue_saved']))
{
require_once '../includes/db_connect.php';
?>
<html>
<table bgcolor='#999999' align='center' width="400px">
<form action="<?php $_SERVER['PHP_SELF']; ?>?stage5" method="POST">
<tr><td width="10px">Username: </td><td><input type='text' name='user_name' maxlength="20" width="400px"  /><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">E-mail Address:</td> <td><input type='text' name='user_email' /><br /></td></tr>
<tr><td width="10px">Confirm E-mail Address: </td><td><input type='text' name='user_email2'/><br /></td></tr>
<tr><td width="10px">Password:</td><td> <input type='password' name='user_password' maxlength="30"/><br /></td></tr>
<tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr>
<tr><td width="10px">Confirm Password:</td><td> <input type='password' name='user_password2'  maxlength="30" /><br /></td></tr>
<tr><td><input type='submit' value='Complete Registration' name='admin_signup' /></td><td><input type="reset" value="Reset Fields" name="reset" /></td></tr>
</form>
</table>
</html>
<?php
mysql_close();
exit();
}
?>
<!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['admin_signup'])){	
require_once '../includes/db_connect.php';
$user_name = mysql_real_escape_string($_POST["user_name"]);		
$user_password =mysql_real_escape_string($_POST["user_password"]);		
$user_password2 =mysql_real_escape_string ($_POST["user_password2"]);
$user_email =mysql_real_escape_string ($_POST["user_email"]);		
$user_email2 =mysql_real_escape_string ($_POST["user_email2"]);
$ip = $_SERVER['REMOTE_ADDR'];
$checkpw = $user_password == $user_password2;
$checkem = $user_email == $user_email2;
if ($user_name && $user_password && $user_password2 && $user_email && $user_email2)
{
		$user_check = mysql_num_rows(mysql_query("SELECT * FROM `$user` WHERE userlevel=1 "));	
		$length = strlen($user_password);
		$length1 = strlen($user_name);
		if ($length >= 6)
				{
					if ($length1 >= 4)
					{
						if ($user_check >= 1)
						{
							echo "Sorry, but the head admin account is already created. Please delete the table in your mysql 		                                database and run the install.php file.";
						}
							elseif ($checkpw.$checkem)
							{
							$userPswd = md5($user_password);
							$userpwsd = sha1($userPswd);
							mysql_query("INSERT INTO `$user` (user_id,  user_name, user_password, user_email, user_ip, userlevel) VALUES ('','$user_name','$userpwsd','$user_email','$ip','1')")
							or die('Error ' . mysql_error());
						require_once 'main_write.php';
						require_once 'redirect_install.php';
							 }
					 }
				} 
						if($length <= 5)
						{

							echo "Password Too Short<br>";
						}

					if($length1 <= 3)
					{

						echo "Username Too Short.<br>";
					}

				if(!$checkpw)
				{

						echo "The passwords you entered do not match. Please check these details and try again.<br>";
				}

			if(!$checkem)
			{

				echo "The emails you entered do not match. Please check these details and try again.<br>";
			}
	}
	else 
		{

			echo "Please fill in all of the required fields.";
		}
mysql_close();
exit();		
}

?><!------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['check']))
{
// Database Connection Information
$dbhost = $_POST["dbhost"];			// Database Host
$dbuser = $_POST["dbuser"];		// Database Username
$dbpass = $_POST["dbpass"];		// Database Password
$dbname = $_POST["dbname"];			// Database Name


// Attempt to connect to the database using the user submitted form.
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if ($con)
{
require_once 'config_write.php';
echo "You have successfully connected with these details to '$dbname'. <br>Username - '$dbuser'<br> Password - '$dbpass'<br> Database Host - '$dbhost'<br>Please enter the table names you want, or if you want to use the preset names click continue. NOTE: Each table must be a different name. Please do not leave any blank spaces.
";
?>
<table align="center" bgcolor="#333333" width="300px" border="0">
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>?stage2">
<tr><td><font color="#FFFFFF">User Details:</td><td><input type='text' name='user' onClick="this.value=''" value="Users"></td></tr>
<tr><td><font color="#ffffff">Forum Questions</td>
<td><input type="text" name='forum_question' onClick="this.value=''" value="questions"></td></tr>
<tr><td><font color='#ffffff'>Forum Answers</td>
<td><input type='text' name='forum_answers' onClick="this.value=''" value="answers"><br></td></tr>
<tr><td></td><td><input type='submit' value='Continue' name='table_names'></td></tr>
</font>
</form>
</table>	
<?php 
}					
else
{
	echo 'Error connecting to database:'  . mysql_error() . '\n';		// Database creation failed
}
mysql_close();
exit();
}
?>
<!------------------------------------------------------------------------------------------------------->
<table align='center' bgcolor="#999999" width='300px' border='0'><form method='post' action="<?php $_SERVER['PHP_SELF']; ?>?stage1">
<tr><td>
Database Host:</td><td>  
<input type='text' name='dbhost' onClick="this.value=''" value="Database Host"><br></td></tr>
<tr><td>
Database Username:</td><td>  
<input type='text' name='dbuser' onClick="this.value=''" value="Database Username"><br></td></tr>
<tr><td>
Database Password:  </td><td>
<input type='text' name='dbpass' onClick="this.value=''" value="Database Password"><br></td></tr>
<tr><td>
Database Name:  </td><td>
<input type='text' name='dbname' onClick="this.value=''" value="Database Name"><br></td></tr>
<tr><td></td><td><input type='submit' value='Continue' name='check'>
</td></tr></form>
</table>
<!------------------------------------------------------------------------------------------------------->

 

if anyone wants to point out errors or anything, please do

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.