Jump to content

PHP form not working!


Ptsface12

Recommended Posts

Hello,

I have tried to make an install, which updates a config file, but what this page does is checks what stage their at, and then writes to the file. But the problem is, when the person adds their details, it refreshes the page, but it doesnt echo a result.

 

Here's the code:

<?php
include 'config.php';
?>
<head>
<title><?php echo $_SESSION['shortname']; ?> - Install PacificCMS </title>
<link rel="stylesheet" href="../css/login.css" />
<style type="text/css">
<!--
.style1 {color: #000000}
-->
</style>
</head>
<body><br><br>
<div id="container">

<div id="head">

<a href="index.php">

	<div id="logo">		</div>
  </a></div>

<div id="login_background">



<div id="login">


<?php
if ((isset($_GET['installed']))&&($_GET['installed'] == '0')) {
echo '<p>Welcome to Pacific CMS installation. This CMS was made by Ptsface12 for Pacific Hotel. You cannot change the Copyright at the bottom unless you have permission from Ptsface12. </p><div> <form method="post" action="install.php?installed=1"><div align="right"><input type="submit" width="100" name="log_button" value="Install" />
        </div>';
}
else {
if ((isset($_GET['installed']))&&($_GET['installed'] == '1')) {
if (isset($_GET['connect'])) {
	$host = $_POST['host'];
        $username = $_POST['username'];
	$password = $_POST['password'];
	$database = $_POST['databasename'];
mysql_connect('$host', '$username', '$password') or die("Unable to connect!");
echo "Connected to Host<br />";
}
echo("Stage 1 - Enter database info</a><br />

      <br />

            <form method=\"post\" action=\"install.php?installed=1\">
              Host
              :<br />

        <input type=\"text\" name=\"host\" value=\"localhost\" onFocus=\"if (this.value == 'localhost') this.value = '';\" />

        Database Username:<br />

        <input type=\"text\" name=\"username\" value=\"root\" onFocus=\"if (this.value == 'root') this.value = '';\" />
        <br />

        Database Password:<br />
        <input type=\"password\" name=\"password\" value=\"Password\" onFocus=\"if (this.value == 'Password') this.value = '';\" />
Database Name:<br />
<input type=\"text\" name=\"databasename\" value=\"pacific_hotel\" onFocus=\"if (this.value == 'database name') this.value = '';\" />
<br />
<br />

        <center><align='right'><input type=\"submit\" id=\"connect\" name=\"connect\" value=\"Sign In\" /></align>");
}
else {
if ((isset($_GET['installed']))&&($_GET['installed'] == '2')) {
echo (" Stage 2 - Hotel Details <br />

      <br />

            <form method=\"post\" action=\"install.php?installed=3\">
              Hotel Full Name 
            :<br />

        <input type=\"text\" name=\"username\" value=\"Pacific Hotel\" onFocus=\"if (this.value == 'Pacific Hotel') this.value = '';\" />

        Hotel Short Name:<br />

        <input type=\"text\" name=\"password\" value=\"Pacific\" onFocus=\"if (this.value == 'Pacific') this.value = '';\" />
        <br />
Hotel Path (<strong>Without Slashes</strong>):<br />
<input type=\"text\" name=\"password:\" value=\"Hotel Path\" onFocus=\"if (this.value == 'Hotel Path') this.value = '';\" />
<br />
<br />

        <center><align='right'><input type=\"submit\" name=\"log_button\" value=\"Step 3\" />
        </align></center>

      </form>");
}
else {
if ((isset($_GET['installed']))&&($_GET['installed'] == '3')) {
echo("Stage 3 - Administrator Account<br />

      <br />

            <form method=\"post\" action=\"install.php?installed=4\">

              Admin Username:<br />
                      <input type=\"text\" name=\"username\" value=\"Pacific\" onFocus=\"if (this.value == 'Username') this.value = '';\" /> 
              Admin Password:
<br />
<input type=\"text\" name=\"password\" value=\"Password\" onFocus=\"if (this.value == 'Password') this.value = '';\" />
Admin Email Address:
<br />
<input type=\"text\" name=\"email\" value=\"Email Address\" onFocus=\"if (this.value == 'Password') this.value = '';\" />
<br />
<br />
<center>
  <align='right'>
  <input type=\"submit\" name=\"createacc\" value=\"Create Account\" />
  </align>");
}
else {
if ((isset($_GET['installed']))&&($_GET['installed'] == '4')) {
$user = $_POST['username'];
$pass = $_POST['password'];
echo ("<p>Pacific CMS has successfully been installed. Your administrator details are: <br>
    Username: <b>$user</b> <br>
    Password: <b>$pass</b></p>
  <p><a href=\"../housekeeping\">Click here for the housekeeping.</a></p>");
}
}
}
}

}
?>

      </form>

    </div>

</div>

</div>

<br />

</body>

 

Here's the code we're looking at:

if ((isset($_GET['installed']))&&($_GET['installed'] == '1')) {
if (isset($_GET['connect'])) {
	$host = $_POST['host'];
        $username = $_POST['username'];
	$password = $_POST['password'];
	$database = $_POST['databasename'];
mysql_connect('$host', '$username', '$password') or die("Unable to connect!");
echo "Connected to Host<br />";
}

No, the problem is not the }, that's further down.

 

Best Wishes,

Ptsface12

Link to comment
https://forums.phpfreaks.com/topic/242636-php-form-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.