Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Error appearing before post?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Disconnect" data-source="post: 311501" data-attributes="member: 53850"><p>[PHP]</p><p><?php</p><p>switch ($step) {</p><p> case 1:</p><p></p><p> if (isset($_POST['submit'])) {</p><p> $db_host = $_POST['hostname'];</p><p> $db_user = $_POST['username'];</p><p> $db_pass = $_POST['password'];</p><p> $db_name = $_POST['database'];</p><p></p><p></p><p> if (!isset($_POST['hostname']) || !isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['database'])) {</p><p> echo '<div class="error">';</p><p> echo 'You\'ve left some fields <b>empty</b>.';</p><p> echo '</div>';</p><p> } elseif (!$db = @mysqli_connect($db_host, $db_user, $db_pass, $db_name)) {</p><p> echo '<div class="error">';</p><p> echo 'Unable to connect to <b>MySQL</b>. <b>Error Code (2002)</b>';</p><p> echo '</div>';</p><p> } else {</p><p> $conf = file_get_contents("../inc/conf.php");</p><p> $conf = str_replace("replace_h", $db_host, $conf);</p><p> $conf = str_replace("replace_u", $db_user, $conf);</p><p> $conf = str_replace("replace_p", $db_pass, $conf);</p><p> $conf = str_replace("replace_n", $db_name, $conf);</p><p> file_put_contents("../inc/conf.php", $conf);</p><p> }</p><p> }</p><p> ?> <form method="post" style="color: rgba(0, 0, 0, 0.43);-webkit-font-smoothing: subpixel-antialiased;"></p><p> <b>Hostname:</b></p><p> <input type="text" name="hostname" class="input" placeholder="Hostname e.g. localhost"/></p><p> <br><br></p><p> <b>Username:</b></p><p> <input type="text" name="username" class="input" placeholder="Username e.g. root"/></p><p> <br><br></p><p> <b>Password:</b></p><p> <input type="password" name="password" class="input" placeholder="Password" /></p><p> <br><br></p><p> <b>Database:</b></p><p> <input type="text" name="database" class="input" placeholder="Database"/></p><p> </div></p><p> <div id="main_box" style="background: #FFF;margin-top: 13px;"></p><p> <input type="submit" name="submit" value="Connect" /></p><p> </form></p><p><?php } ?></p><p>[/PHP]</p><p>Try that</p></blockquote><p></p>
[QUOTE="Disconnect, post: 311501, member: 53850"] [PHP] <?php switch ($step) { case 1: if (isset($_POST['submit'])) { $db_host = $_POST['hostname']; $db_user = $_POST['username']; $db_pass = $_POST['password']; $db_name = $_POST['database']; if (!isset($_POST['hostname']) || !isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['database'])) { echo '<div class="error">'; echo 'You\'ve left some fields <b>empty</b>.'; echo '</div>'; } elseif (!$db = @mysqli_connect($db_host, $db_user, $db_pass, $db_name)) { echo '<div class="error">'; echo 'Unable to connect to <b>MySQL</b>. <b>Error Code (2002)</b>'; echo '</div>'; } else { $conf = file_get_contents("../inc/conf.php"); $conf = str_replace("replace_h", $db_host, $conf); $conf = str_replace("replace_u", $db_user, $conf); $conf = str_replace("replace_p", $db_pass, $conf); $conf = str_replace("replace_n", $db_name, $conf); file_put_contents("../inc/conf.php", $conf); } } ?> <form method="post" style="color: rgba(0, 0, 0, 0.43);-webkit-font-smoothing: subpixel-antialiased;"> <b>Hostname:</b> <input type="text" name="hostname" class="input" placeholder="Hostname e.g. localhost"/> <br><br> <b>Username:</b> <input type="text" name="username" class="input" placeholder="Username e.g. root"/> <br><br> <b>Password:</b> <input type="password" name="password" class="input" placeholder="Password" /> <br><br> <b>Database:</b> <input type="text" name="database" class="input" placeholder="Database"/> </div> <div id="main_box" style="background: #FFF;margin-top: 13px;"> <input type="submit" name="submit" value="Connect" /> </form> <?php } ?> [/PHP] Try that [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Error appearing before post?
Top