Jump to content

Russia

Members
  • Posts

    419
  • Joined

  • Last visited

Everything posted by Russia

  1. Hey guys, I have this curl script I am working on, for some reason it wont work and keeps returning Invalid GUID. Here is the code to the install script with curl in it: <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { function realEscape($string) { if(get_magic_quotes_gpc()) { return mysql_real_escape_string(stripslashes($string)); } else { return mysql_real_escape_string($string); } } function encrypt($value) { return md5(md5(base64_encode($value))); } if(isset($_GET['guid'])) { $my_guid = $_GET['guid']; } elseif(isset($_POST['guid1'])) { $my_guid = $_POST['guid1'] .'-'. $_POST['guid2'] .'-'. $_POST['guid3'] .'-'. $_POST['guid4']; } if(function_exists('curl_open')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.example.info/guid/4/guid4.php'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'MRSW'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'guid='.urlencode($my_guid) . '&webaddress=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'])) .'&version='. urlencode($version); $output = curl_exec($ch); if(preg_match('/valid=([A-Z0-9\-]+)/', $output, $matches)) { $valid = $matches[1]; } curl_close($ch); } elseif($sock = @fsockopen('208.89.214.34', 80)) { $request = "POST /guid/4/guid4_3.php HTTP/1.1\r\n". "Host: example.info\r\n". "Connection: Close\r\n". "User-Agent: MRSW\r\n". "Content-Type: application/x-www-form-urlencoded\r\n". "Content-Length: ". strlen('guid='.urlencode($my_guid) . '&webaddress=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']) ."&version". urlencode($version)) ."\r\n\r\n". 'guid='.urlencode($my_guid) . '&webaddress=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']) .'&version='. urlencode($version); fwrite($sock, $request); while($buf = fgets($sock)) { if(preg_match('/valid=([A-Z0-9\-]+)/', $buf, $matches)) { $valid = $matches[1]; } } fclose($sock); } if($valid == 1) { if($_GET['step'] == 1) { echo 'GUID is valid.'; echo '<form action="install2.php?step=2&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Continue">'; echo '</form>'; } if($_GET['step'] == 2) { if (is_writable('../includes/config.php')) { echo '<font color="green">File config.php is writable.</font><br />'; echo '<form action="install2.php?step=3&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Continue">'; echo '</form>'; } else { echo '<font color="red">Can not write to config.php, If you have not done so, please CHMOD config.php to 777.</font>'; } } if($_GET['step'] == 3) { if($_GET['check'] == 1) { /* ***************************************** * Database Connection check ***************************************** */ $con = @mysql_connect($_POST['host'], $_POST['user'], $_POST['pass']); @mysql_select_db($_POST['db'], $con); if(!$con) { echo "<br /><br /><b>Could not connect to:<br>Host: ". $_POST['host'] ."<br>User: ". $_POST['user'] ."<br>Database: ". $_POST['db'] ."<br>Using password: "; if(empty($_POST['pass'])) { echo "No"; } else { echo "yes"; } echo "<br /></b>"; echo '<form action="install2.php?step=6" method="post">'; echo '<input type="submit" value="Try Again">'; echo '</form>'; } else { /* ***************************************** * Config.php Creation ***************************************** */ $extra = '../includes/config.php'; $filename = "../includes/config.php"; $somecontent = "<?php \$guid = '". $my_guid ."';\$host = '". $_POST['host'] ."';\$dbuser = '". $_POST['user'] ."';\$dbpass = '". $_POST['pass'] ."';\$db = '". $_POST['db'] ."';\$prefix = '". $_POST['prefix'] ."'; "; if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } fclose($handle); echo "MySQL Successfully connected."; echo '<form action="install2.php?step=4&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Continue">'; echo '</form>'; } } else { echo '<table width="325" border="0" align="center">'; echo '<form action="install2.php?step=3&check=1&guid='. $my_guid .'" method="post">'; echo '<tr><td>MySQL Host:</td><td><input type="text" name="host"></td></tr>'; echo '<tr><td>MySQL Username:</td><td><input type="text" name="user"></td></tr>'; echo '<tr><td>MySQL Password:</td><td><input type="password" name="pass"></td></tr>'; echo '<tr><td>MySQL Database:</td><td><input type="text" name="db"></td></tr>'; echo '<tr><td>Database Prefix:</td><td><input type="text" name="prefix"></td></tr>'; echo '<tr><td><input type="submit" value="Continue"></td></tr>'; echo '</form>'; echo '</table>'; } } if($_GET['step'] == 4) { include '../includes/config.php'; $con = @mysql_connect($host, $dbuser, $dbpass); mysql_select_db($db ,$con); //tables echo 'Successfully created Tables'; echo '<form action="install2.php?step=5&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Continue">'; echo '</form>'; } if($_GET['step'] == 5) { if($_GET['check'] == 1) { include '../includes/config.php'; $con = @mysql_connect($host, $dbuser, $dbpass); mysql_select_db($db ,$con); if($_POST['forum'] == 1) { //options echo 'Options successfully inserted.'; echo '<form action="install2.php?step=6&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Continue">'; echo '</form>'; } else { echo '<table width="325" border="0" align="center">'; echo '<form action="install2.php?step=5&check=1&guid='. $my_guid .'" method="post">'; echo '<tr><td>Website Title:</td><td><input type="text" name="title"></td></tr>'; echo '<tr><td>Forums Type:</td><td><select name="forum" onchange="displayforum();"><option value="0">MikeRSWeb Forums</option><option value="1">Other Forums</option></select></td></tr>'; echo '<tr><td>Forums Link:</td><td id="forum" style="display: none"><input class="input" name="forums" type="text" id="forums"></td></tr>'; echo '<tr><td>Client Type:</td><td><select name="client" id="ctype" onchange="displayclient();"><option value="0">MikeRSWeb Webclient</option><option value="1">Custom Client</option></select></td></tr>'; echo '<tr><td>Client Link:</td><td id="client" style="display: none"><input type="text" name="client" id="client"></td></tr>'; echo '<tr><td>Website Theme:</td><td><select name="theme"><option value="0">Normal</option><option value="1">Metal</option><option value="2">Halloween</option><option value="3">Christmas</option><option value="4">Castle</option></select></td></tr>'; echo '<tr><td>Server IP:</td><td><input type="text" name="ip"></td></tr>'; echo '<tr><td>Server Port:</td><td><input type="text" name="port"></td></tr>'; echo '<tr><td><input type="submit" value="Continue"></td></tr>'; echo '</form>'; echo '</table>'; ?> <script> document.getElementById('client').style.display = 'none'; function displayclient() { e = document.forms[0].ctype.value; if(e == 0) { document.getElementById('client').style.display = 'none'; } else { document.getElementById('client').style.display = 'block'; } } document.getElementById('forum').style.display = 'none'; function displayforum() { e = document.forms[0].forum.value; if(e == 0) { document.getElementById('forum').style.display = 'none'; } else { document.getElementById('forum').style.display = 'block'; } } </script> <?php } } if($_GET['step'] == 6) { if($_GET['check'] == 1) { if(!is_numeric($_POST['day']) || !is_numeric($_POST['month']) || !is_numeric($_POST['year'])) { echo 'Every field from your birthdate has to be numeric.<br />'; echo '<form action="install2.php?step=6&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Try Again">'; echo '</form>'; } elseif(!in_array($_POST['theme'], array(0, 1, 2, 3, 4))) { echo 'Invalid theme.<br />'; echo '<form action="install2.php?step=6&guid='. $my_guid .'" method="post">'; echo '<input type="submit" value="Try Again">'; echo '</form>'; } else { include '../includes/config.php'; $con = @mysql_connect($host, $dbuser, $dbpass); mysql_select_db($db ,$con); //others if(function_exists('curl_open')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.example.info/guid/4/guid4_end.php'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'MRSW'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'guid='.urlencode($my_guid) . '&webaddress=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']) . '&version='. $version); $output = curl_exec($ch); if(preg_match('/valid=([A-Z0-9\-]+)/', $output, $matches)) { $valid = $matches[1]; } curl_close($ch); } elseif($sock = @fsockopen('208.89.214.34', 80)) { $request = "POST /guid/4/guid4_3_end.php HTTP/1.1\r\n". "Host: example.info\r\n". "Connection: Close\r\n". "User-Agent: MRSW\r\n". "Content-Type: application/x-www-form-urlencoded\r\n". "Content-Length: ". strlen('guid='.urlencode($my_guid) . '&webaddress=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']) ."&version=". $version) ."\r\n\r\n". 'guid='.urlencode($my_guid) . '&webaddress=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']) .'&version='. urlencode($version); fwrite($sock, $request); while($buf = fgets($sock)) { if(preg_match('/valid=([A-Z0-9\-]+)/', $buf, $matches)) { $valid = $matches[1]; } } fclose($sock); } echo 'MikeRSWeb has been successfully installed. <br />Thank you for installing MikeRSWeb. <a href="../index.php">Click here to continue</a>.'; } } else { echo '<table width="325" border="0" align="center">'; echo '<form action="install2.php?step=6&check=1&guid='. $my_guid .'" method="post">'; echo '<tr><td>Administrator Username:</td><td><input type="text" name="username"></td></tr>'; echo '<tr><td>Administrator Password:</td><td><input type="password" name="password"></td></tr>'; echo '<tr><td>Date Of Birth:</td><td><select id="day" name="day"> <option value="-1" selected="selected" disabled="disabled">Day</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select id="month" name="month"> <option value="-1" selected="selected" disabled="disabled">Month</option> <option value="0">January</option> <option value="1">February</option> <option value="2">March</option> <option value="3">April</option> <option value="4">May</option> <option value="5">June</option> <option value="6">July</option> <option value="7">August</option> <option value="8">September</option> <option value="9">October</option> <option value="10">November</option> <option value="11">December</option> </select> <input type="text" id="year" name="year" maxlength="4" value="Year"></td></tr>'; echo '<tr><td>Administrator E-Mail:</td><td><input type="text" name="email"></td></tr>'; echo '<tr><td><input type="submit" value="Continue"></td></tr>'; echo '</form>'; echo '</table>'; } } } else { echo 'This GUID is not Valid. Register on www.example.info for a valid GUID.'; } } else { ?> <div id="body"> <center> <h3>Install</h3> <em>Welcome to the MikeRSWeb Installation page. We will work in steps to get to your final destination of getting MikeRSWeb working</em></P> <p><strong>________________________________________________</strong></p> </center> <form action="install2.php?step=1" method="post" name="install"> <table width="325" align="center" border="0"> <tbody><tr> <td>Register at www.example.info for a GUID Code</td> </tr> <tr> <td>Your GUID Code: <input style="width: 35px;" name="guid1" maxlength="4" type="text"> - <input style="width: 35px;" name="guid2" maxlength="4" type="text"> - <input style="width: 35px;" name="guid3" maxlength="4" type="text"> - <input style="width: 35px;" name="guid4" maxlength="4" type="text"></td> </tr> <tr> <td><input class="button-bg" value="Continue" type="submit"></td> </tr> </tbody></table> </form> </div> <?php } ?> You can see it connects to example.info/guid/4/guid.php This is where it checks if the guid is valid from a database. Here is the info from the guid.php page: <?php $con = @mysql_connect('localhost','brian_brian','******'); mysql_select_db('brian_brian' ,$con); function realEscape($string) { if(get_magic_quotes_gpc()) { return mysql_real_escape_string(stripslashes($string)); } else { return mysql_real_escape_string($string); } } if($_SERVER['HTTP_USER_AGENT'] == 'MRSW' && !empty($_POST['guid'])) { $check_guid_exist = mysql_query('SELECT guid FROM guids2 WHERE guid="'. realEscape($_POST['guid']) .'" AND `used`=0'); if(mysql_num_rows($check_guid_exist) > 0) { $result = mysql_query('SELECT banned FROM guids2 WHERE guid = \''.$_POST['guid'] .'\''); $row = mysql_fetch_assoc($result); if(!(int)$row['banned']) { echo 'valid=1'; } } else { echo 'valid=0'; } } ?> For some reason it wont work, also, see this line: elseif($sock = @fsockopen('208.89.214.34', 80)) For the IP Address what do I put there? My IP address or the website's IP Address? Thanks ahead of time for the help. Also, if someone needs a picture of how the database looks just post here.
  2. WOO!! that simple.... crap i feel like an idiot, also, can I ask for one more thing, I would also like to add a message if the key has already been used, that means that if activation column is already set to yes it gives an error message saying like License key already used. How am I able to do that?
  3. ALright, I changed the name of the key instead to key_name, but it still gives me the same error. I dont get why it does that? ALso, only the column name cant be key or keys correct?
  4. key is the data from the form... its the column were the keys are stored...
  5. Alright, I was able to fix that too. Now I have another problem, some kind of syntax error: no key found You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'keys WHERE key=''' at line 1 This is the line its talking about $query = "SELECT * FROM keys WHERE key='".$key."'"; I think its that last part, were its using the $key variable. Are the single quotes, periods, or quotes around it messing it up? from this whole script: <?php if (isset ($_POST['submit'])) // if the form was submitted, display their name { mysql_connect("localhost", "brian_keys", "*******") or die(mysql_error()); mysql_select_db("brian_keys") or die(mysql_error()); $key = addslashes(htmlentities($_POST['key'])); if ($key == "") { echo "no key found"; } $query = "SELECT * FROM keys WHERE key='".$key."'"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) > 0) { echo "Key valid"; // Setting the key activated $query = "UPDATE keys SET activation='yes' WHERE key='".$key."'"; $result = mysql_query($query); } else { echo "Key invalid"; } } else // form hasn't been submitted, so display the form { ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="key"> <input type="submit" name="submit" value="Submit!"> </form> <?php } ?>
  6. Oh, got it to work, now it gives me a new error when I proccess the form, it says: Could not execute query Its part of the OR DIE thing. Is it because it cannot find the table or why? <?php if (isset ($_POST['submit'])) // if the form was submitted, display their name { mysql_connect("localhost", "brian_keys", "123321") or die(mysql_error()); mysql_select_db("brian_keys") or die(mysql_error()); $key = addslashes(htmlentities($_POST['key'])); if ($key == "") { echo "no key found"; } $query = "SELECT * FROM keys WHERE key='".$key."'"; $result = mysql_query($query) or die("Could not execute query"); if (mysql_num_rows($result) > 0) { echo "Key valid"; // Setting the key activated $query = "UPDATE keys SET activation='yes' WHERE key='".$key."'"; $result = mysql_query($query); } else { echo "Key invalid"; } } else // form hasn't been submitted, so display the form { ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="key"> <input type="submit" name="submit" value="Submit!"> </form> <?php } ?> Is it unable to get the table or the column?
  7. ALright, I found and fixed the error, but now the form shows up and doesnt work, it goes to pho self but doesnt give an error when there is no key entered, invalid or valid, it just reshows the form, what am I doing wrong??? <?php if (isset ($_POST['submit'])) // if the form was submitted, display their name { mysql_connect("localhost", "brian_keys", "******") or die(mysql_error()); mysql_select_db("brian_keys") or die(mysql_error()); $key = addslashes(htmlentities($_POST['key'])); if ($key == "") { echo "no key found"; } $query = "SELECT * FROM keys WHERE key='".$key."'"; $result = mysql_query($query) or die("Could not execute query"); if (mysql_num_rows($result) > 0) { echo "Key valid"; // Setting the key activated $query = "UPDATE keys SET activation='yes' WHERE key='".$key."'"; $result = mysql_query($query); } else { echo "Key invalid"; } } else // form hasn't been submitted, so display the form { ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <input type="text" name="key"> <input type="submit" value="Submit!"> </form> <?php } ?>
  8. <?php mysql_connect("localhost", "brian_keys", "123321") or die(mysql_error()); mysql_select_db("brian_keys") or die(mysql_error()) if (isset ($_POST['submit'])) // if the form was submitted, display their name { $key = addslashes(htmlentities($_POST['key'])); if ($key == "") { die("No key found"); } $query = "SELECT * FROM keys WHERE key='".$key."'"; $result = mysql_query($query) or die("Could not execute query"); if (mysql_num_rows($result) > 0) { echo "Key valid"; // Setting the key activated $query = "UPDATE keys SET activation='yes' WHERE key='".$key."'"; $result = mysql_query($query); } else { echo "Key invalid"; } } else // form hasn't been submitted, so display the form { ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="key"> <input type="submit" value="Submit!"> </form> <?php } ?> ALright I fixed it, but it still wont show up... Whats the problem in the coding???
  9. I currently have this code: <?php mysql_connect("localhost", "brian_keys", "******") or die(mysql_error()); mysql_select_db("brian_keys") or die(mysql_error()) if (isset ($_POST['submit'])) // if the form was submitted, display their name { $key = addslashes(htmlentities($_POST['key'])); if ($key == "") { die("No key found"); } $query = "SELECT * FROM keys WHERE key='".$key."'"; $result = mysql_query($query) or die("Could not execute query"); if (mysql_num_rows($result) > 0) { echo "Key valid"; // Setting the key activated $query = "UPDATE keys SET activation='yes' WHERE key='".$key."'"; $result = mysql_query($query); } else { echo "Key invalid"; } } else // form hasn't been submitted, so display the form { echo '<form method="POST" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> <input type="text" name="key"> <input type="submit" value="Submit!"> </form>'; } ?> Its a form to check if the licence key someone provided during an installation of a script is valid or not, you enter the key in the form and it tells you if its valid, used or invalid. For some reason the form wont show up at all and there seems to be no errors in the coding, does anyone spot the problem? Thanks in advance.
  10. Hey guys, I am trying to add form validation to my form like if the fields were filled out or not, I got it to work for the first form, to show the error on THE SAME PAGE, thats the whole thing I need, for it to show the error on the same page. Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Website Installation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="installer-styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <a href="installer.php">Website Installation</a> </div> <div id="main"> <div class="pad25"> <?php if( isset( $_POST['submit'] ) ) { if( $_POST['nextstep'] == "checkuser" ) { //start function for the checkuser stage if( empty( $_POST['db_name'] ) || empty( $_POST['db_user'] ) || empty( $_POST['db_pass'] ) || empty( $_POST['db_host'] ) ) { $error = "form not fully filled, reshow first form"; }else{ $form = ' <FORM method="post" action="' . $_SERVER['PHP_SELF'] . '"> second form<br> <input type="text" name="user3"><br> <input type="text" name="user4"><br> <input type="hidden" name="nextstep" value="checkanswer"> <input type="submit" name="submit" value="Submit Form"><br> </FORM>'; } //end function for the checkuser stage }elseif ($_POST['nextstep']=="checkanswer") { //start function for the checkanswer stage if(empty($_POST['user3']) || empty($_POST['user4']) ) { $error = "form not fully filled, reshow first second"; }else{ } //start function for the checkuser stage } if(isset($error)){ echo "<p class=\"error\">" . $error . "</a>"; } } if( isset($form) ) { echo $form; }else{ ?> <h1>Step 1: Database Information</h1><br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form"> <p>Enter your database connection settings. These settings will be inserted into <code>inc/config.inc.php</code> and will be used by the application.</p> <table style="width: 100%;"> <tr> <th class="col1">Database Name</th> <td class="col2"><input name="db_name" type="text" size="20" /></td> <td class="col3">The name of the database to use.</td> </tr> <tr> <th class="col1">Username</th> <td class="col2"><input name="db_user" type="text" size="20" /></td> <td class="col3">Your MySQL username.</td> </tr> <tr> <th class="col1">Password</th> <td class="col2"><input name="db_pass" type="password" size="20" /></td> <td class="col3">Your MySQL password.</td> </tr> <tr> <th class="col1">Database Host</th> <td class="col2"><input name="db_host" type="text" size="20" value="localhost" /></td> <td class="col3">Most likely won't need to change this value.</td> </tr> </table><br /> <input type="hidden" name="nextstep" value="checkuser"> <input type="submit" name="submit" class="button" style="float:right;" value="Submit Form ›"><br> </form> <?php } ?> </div> </div> <br class="clr" /> </div> <br class="clr" /> <div id="footer"> <div class="footer_inner">© 2010 | Bucket</div> </div> </body> </html> I made the error show up for the first form, but cant get it to work on the second form, when the second form gets filled out not all the way, it shows the error on the first for, I am trying to make it show the error on the second. Can someone help me out please? This is what I had before, it worked fine, but I hated that the errors would be shown on another page after submit. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Website Installation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="installer-styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <a href="installer.php"> Website Installation</a> </div> <div id="main"> <div class="pad25"> <?php if(isset($_POST['submit'])) { if ($_POST['nextstep']=="checkuser") { //start function for the checkuser stage if(empty($_POST['db_name']) || empty($_POST['db_user']) || empty($_POST['db_pass']) || empty($_POST['db_host']) ) { echo "form not fully filled, reshow first form"; } else { ?> <HTML> <HEAD><title>Using PHP_SELF</title></HEAD> <BODY> <FORM method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> second form<br> <input type="text" name="user3"><br> <input type="text" name="user4"><br> <input type="hidden" name="nextstep" value="checkanswer"> <input type="submit" name="submit" value="Submit Form"><br> </FORM> </BODY> </HTML> <?php } //end function for the checkuser stage ?> <?php } if ($_POST['nextstep']=="checkanswer") { //start function for the checkanswer stage if(empty($_POST['user3']) || empty($_POST['user4']) ) { echo "form not fully filled, reshow first second"; } else { ?> complete <?php } //start function for the checkuser stage ?> <?php } } else { ?> <h1>Step 1: Database Information</h1><br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form"> <p>Enter your database connection settings. These settings will be inserted into <code>inc/config.inc.php</code> and will be used by the application.</p> <table style="width: 100%;"> <tr> <th class="col1">Database Name</th> <td class="col2"><input name="db_name" type="text" size="20" /></td> <td class="col3">The name of the database to use.</td> </tr> <tr> <th class="col1">Username</th> <td class="col2"><input name="db_user" type="text" size="20" /></td> <td class="col3">Your MySQL username.</td> </tr> <tr> <th class="col1">Password</th> <td class="col2"><input name="db_pass" type="password" size="20" /></td> <td class="col3">Your MySQL password.</td> </tr> <tr> <th class="col1">Database Host</th> <td class="col2"><input name="db_host" type="text" size="20" value="localhost" /></td> <td class="col3">Most likely won't need to change this value.</td> </tr> </table><br /> <input type="hidden" name="nextstep" value="checkuser"> <input type="submit" name="submit" class="button" style="float:right;" value="Submit Form ›"><br> </form> <?php } ?> </div> </div> <br class="clr" /> </div> <br class="clr" /> <div id="footer"> <div class="footer_inner"> © 2010 | Bucket </div> </div> </body> </html> Thank you for the help.
  11. I am trying to change my script to show the error message on the same page, above the form instead of on another page, that I current have coded. The thing is I do not know how to do that. Can someone help me out by showing how to do it? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Website Installation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="installer-styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <a href="installer.php"> Website Installation</a> </div> <div id="main"> <div class="pad25"> <?php if(isset($_POST['submit'])) { if ($_POST['nextstep']=="checkuser") { //start function for the checkuser stage if(empty($_POST['db_name']) || empty($_POST['db_user']) || empty($_POST['db_pass']) || empty($_POST['db_host']) ) { echo "form not fully filled, reshow first form"; } else { ?> <HTML> <HEAD><title>Using PHP_SELF</title></HEAD> <BODY> <FORM method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> second form<br> <input type="text" name="user3"><br> <input type="text" name="user4"><br> <input type="hidden" name="nextstep" value="checkanswer"> <input type="submit" name="submit" value="Submit Form"><br> </FORM> </BODY> </HTML> <?php } //end function for the checkuser stage ?> <?php } if ($_POST['nextstep']=="checkanswer") { //start function for the checkanswer stage if(empty($_POST['user3']) || empty($_POST['user4']) ) { echo "form not fully filled, reshow first second"; } else { ?> complete <?php } //start function for the checkuser stage ?> <?php } } else { ?> <h1>Step 1: Database Information</h1><br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form"> <p>Enter your database connection settings. These settings will be inserted into <code>inc/config.inc.php</code> and will be used by the application.</p> <table style="width: 100%;"> <tr> <th class="col1">Database Name</th> <td class="col2"><input name="db_name" type="text" size="20" /></td> <td class="col3">The name of the database to use.</td> </tr> <tr> <th class="col1">Username</th> <td class="col2"><input name="db_user" type="text" size="20" /></td> <td class="col3">Your MySQL username.</td> </tr> <tr> <th class="col1">Password</th> <td class="col2"><input name="db_pass" type="password" size="20" /></td> <td class="col3">Your MySQL password.</td> </tr> <tr> <th class="col1">Database Host</th> <td class="col2"><input name="db_host" type="text" size="20" value="localhost" /></td> <td class="col3">Most likely won't need to change this value.</td> </tr> </table><br /> <input type="hidden" name="nextstep" value="checkuser"> <input type="submit" name="submit" class="button" style="float:right;" value="Submit Form ›"><br> </form> <?php } ?> </div> </div> <br class="clr" /> </div> <br class="clr" /> <div id="footer"> <div class="footer_inner"> © 2010 | Bucket </div> </div> </body> </html> I currently have the else message echoing on a different page.
  12. So your lonely? Hm... make friends on forums... Make a myspace and invite your friends at school...
  13. So something like this? <?php $email = $_POST['email_address']; $form = '<form action="" method="POST"> Email Address: <input size="40" type="text" value="' . $_POST["email_address"] . '" name="email_address"><br> Username <input size="40" type="text" value="' . $_POST["username"] . '" name="username"><br> password <input size="40" value="' . $_POST["password"] . '" type="text" name="password"><br> <input id="submit" class="submit-button" type="submit" name="submit" value="Reset Password" > </form>'; if (isset($_POST['submit'])) { $blank_inputs = 0; $test_array = array_count_values($_POST); $blank_inputs = $test_array[""]; if (($blank_inputs > 0) || (preg_match("/^[a-z0-9._-]+?@[a-z0-9-]+?(?:\.[a-z]{1,4}){1,2}$/i",$_POST['email']))) { //display an error message and put the form back up for editing echo "Please fill out the whole form.<hr>"; echo $form; } else { echo 'message sent'; } } else { echo $form; } ?> Also, what does || mean in php?
  14. No, to see if its in the correct format. Something like: ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email); But where would I add that?
  15. I would also like to add a email validation to it. How would I go about doing that without messing up the coding? So basically even if the whole form is filled out, and the email is in the wrong format, then do the same thing as when the form isn't totally filled out. If the email is in the correct format but the whole form isnt filled out, then show an error message, I already have all that coded in, exept the email validation. Can someone add that to my code? <?php $form = '<form action="" method="POST"> Email Address: <input size="40" type="text" value="' . $_POST["email_address"] . '" name="email_address"><br> Username <input size="40" type="text" value="' . $_POST["username"] . '" name="username"><br> password <input size="40" value="' . $_POST["password"] . '" type="text" name="password"><br> <input id="submit" class="submit-button" type="submit" name="submit" value="Reset Password" > </form>'; if (isset($_POST['submit'])) { $blank_inputs = 0; $test_array = array_count_values($_POST); $blank_inputs = $test_array[""]; if ($blank_inputs > 0) { //display an error message and put the form back up for editing echo "Please fill out the whole form.<hr>"; echo $form; } else { echo 'message sent'; } } else { echo $form; } ?>
  16. Something like? $handle = fopen("http://www.example.com/", "rb"); $data = stream_get_contents($handle); fclose($handle); $find = "Find me"; $pos = strpos($data, $find); if ($pos === 0) { // Not found... echo "Not found..."; } else { // Found! echo "Found!!!!"; }
  17. So something like this? <?php $pagedata = file_get_contents("http://example.com/profile/user_bucket.php"); if (preg_match("/User is Online./i", $pagedata)) { echo = "user is online"; } else (preg_match("/User is Offline./i", $pagedata)) { echo = "user is offline"; } ?> So basically if the user named Bucket is online on his profile and it looks for the word "online" or "offline" it will come back and tell me if he is?
  18. How would i do that? Can you show me how I would write it up so it gets it from a website. Thanks.
  19. I am trying to find out what this is called. Its like when you get a webpages contents, and if certain words that you are looking for are found then it will say something, if the words you are looking for are not found, then say something else. What is that called? I think curl is used for it. Example: if (preg_match("/User is Online./i", $pagedata)) { echo = "user is online"; } else (preg_match("/User is Offline./i", $pagedata)) { echo = "user is offline"; } I have no idea what its called or how to do it.
  20. I have figured out that I had an error with the html not the actual PHP. Thank You All.
×
×
  • 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.