Jump to content

[SOLVED] Looks complicated.But isn't. Just a lot to read


DeanWhitehouse

Recommended Posts

I am trying to intergrate several forms, into one page.

this is my code

<?php
/*Random Game Design: PHP Website Template/CMS
Version 1
Copyright Dean Whitehouse, 2008*/

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)
  {
  die('Could not connect: ' . mysql_error());
  }
  // Error, connection cannot be made
if ($con)
{
include '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' value='rgd_users'><br></td></tr>
<tr><td><font color='#ffffff'>Forum Questions</td>
<td><input type='text' name='forum_question' value='forum_question'></td></tr>
<tr><td><font color='#ffffff'>Forum Answers</td>
<td><input type='text' name='forum_answers' value='forum_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
?>
<p>Welcome to the random game design website template. Please follow this set-up and then you can customise your site fully.<br>Plese only click this button once, as it will reset your progress.<form method='post' action="<?php $_SERVER['PHP_SELF']; ?>"><input type='submit' value='Start' name='start'></form>
</p>
<?php
}
// Close connection to the database
mysql_close();
}

if(isset($_POST['start']))
{
echo ('Please enter the details used to connect to your MySql database.');
?>
<table align='center' bgcolor='#333333' width='300px' border='0'><form method='post' action="<?php $_SERVER['PHP_SELF']; ?>">
<tr><td>
Database Host:</td><td>  
<input type='text' name='dbhost'><br></td></tr>
<tr><td>
Database Username:</td><td>  
<input type='text' name='dbuser'><br></td></tr>
<tr><td>
Database Password:  </td><td>
<input type='text' name='dbpass'><br></td></tr>
<tr><td>
Database Name:  </td><td>
<input type='text' name='dbname'><br></td></tr>
<tr><td></td><td><input type='submit' value='Continue' name='check'>
</td></tr></form>
</table>
<?php
}
else
{
?>
<p>Welcome to the random game design website template. Please follow this set-up and then you can customise your site fully.<br>Plese only click this button once, as it will reset your progress.<form method='post' action="<?php $_SERVER['PHP_SELF']; ?>"><input type='submit' value='Start' name='start'></form>
</p>
<?php
}
?>

 

ok, the first form on the list(which is the second one displayed)

shows this underneath it

<p>Welcome to the random game design website template. Please follow this set-up and then you can customise your site fully.<br>Plese only click this button once, as it will reset your progress.<form method='post' action="<?php $_SERVER['PHP_SELF']; ?>"><input type='submit' value='Start' name='start'></form>

 

How can  i fix it, i only want to show that if they haven't clicked start( i am planning on adding sessions for security) could i use them to do it?

Link to comment
Share on other sites

anyone , this is just the part that isn't working properly

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)
  {
  die('Could not connect: ' . mysql_error());
  }
  // Error, connection cannot be made
if ($con)
{
include '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' value='rgd_users'><br></td></tr>
<tr><td><font color='#ffffff'>Forum Questions</td>
<td><input type='text' name='forum_question' value='forum_question'></td></tr>
<tr><td><font color='#ffffff'>Forum Answers</td>
<td><input type='text' name='forum_answers' value='forum_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
?>
<p>Welcome to the random game design website template. Please follow this set-up and then you can customise your site fully.<br>Plese only click this button once, as it will reset your progress.<form method='post' action="<?php $_SERVER['PHP_SELF']; ?>"><input type='submit' value='Start' name='start'></form>
</p>
<?php
}
// Close connection to the database
mysql_close();
}
else
{
?>
<p>Welcome to the random game design website template. Please follow this set-up and then you can customise your site fully.<br>Plese only click this button once, as it will reset your progress.<form method='post' action="<?php $_SERVER['PHP_SELF']; ?>"><input type='submit' value='Start' name='start'></form>
</p>
<?php

}

 

any help would be really good, the problem is this

else
{
?>
<p>Welcome to the random game design website template. Please follow this set-up and then you can customise your site fully.<br>Plese only click this button once, as it will reset your progress.<form method='post' action="<?php $_SERVER['PHP_SELF']; ?>"><input type='submit' value='Start' name='start'></form>
</p>
<?php

}

shows all the time

Link to comment
Share on other sites

ok, after the database details form it prints this

Array ( [dbhost] => *** [dbuser] => *** [dbpass] => *** [dbname] => **** [check] => Continue )

with detials init but i have hidden these on the above version

and on the second form it prints this

Array ( [user] => rgd_users [forum_question] => forum_question [forum_answers] => forum_answers [table_names] => Continue )

Link to comment
Share on other sites

Try doing this:

 

Remove these lines:

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

  // Error, connection cannot be made

 

Add exit(); after this:

<td><input type='text' name='forum_answers' value='forum_answers'><br></td></tr>

<tr><td></td><td><input type='submit' value='Continue' name='table_names'></td></tr>

</font>

</form>

 

</table>

Link to comment
Share on other sites

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.