Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I was speaking of either open-source or third party.
  2. That is going to be VERY hard to accomplished. he's right the cron job should do comparisons. Set it up to check at one time for what sessions are there. 10 minutes later check again for any that are not there that were there and log. (means they logged off or whatever so record it). Then do it again every 30 minutes to keep tabs. Aside from that, you can check on other languages, and maybe if you can install something you can get an app, or session utility that can do something like that on the server possibly but I have never heard about one before.
  3. It looks like it's working. It takes you to the success page which is what you wanted?
  4. Post ALL of your code. The include, the registration page, and the other page.
  5. Technically you can have one as far down as you want as long as there is nothing outputted to the browser before it shows. I see nothing there that outputs before the header, but yeah he's right, check the included file. That's why i stated, try that. If it doesn't work post the exact error message.
  6. header("Location: url"); if that doesn't work then paste the error.
  7. Post all relevant code real quick, and walk me through what it's suppose to do and what it's not doing (as opposed to what it should be) so I can get a better idea of what is going on. Then let me see if I can rewrite it to work for you.
  8. * Create a list of users from the database. * Build dynamic url's with their id at the end. * Grab the id on the other page. * Run a query with it to get the data (using where to get the right id)
  9. It should happen by default in almost all browsers. If it doesn't then it has something to do with what your doing (post your code). http://www.google.com/search?hl=en&q=hit+enter+on+form peruse some stuff there and see what you get.
  10. You are confusing me, so let me just offer what I see. Just a few points is all I can offer until I understand better. <select id=menu$num name=menu$num><option value=default$num SELECTED>$desc</option> <option value=option1_$num>Option 1</option> <option value=option2_$num>Option 2</option> <option value=option3_$num>Option 3</option> <option value=option4_$num>Option 4</option> <option value=option5_$num>Option 5</option> <option value=option6_$num>Option 6</option> <option value=option7_$num>Option 7</option> <option value=option8_$num>Option 8</option> </select> <input type=text name=deb$num value=\"$var1[$num]\" style=color:FF0000 readonly=yes> <input type=text name=cred$num value=\"$var2[$num]\" readonly=yes> The deb$num part it's happening. You have to have the $num inside php tags, and the point is it has to be populates. If this is coming from the db as you said then it's goign to be a paid with the $num all over the place because you can't tell what it is, you have no way of accessing cred without knowing what num is.
  11. If it's in the select then they can only choose one. So if you are saving it in an array as i showed,then no matter WHAT is in it it'll pass the right variable. Actually wait, that won't work. <select name="whatever"> // now put all your options </select> Whatever is selected is available via $_POST['whatever'] no matter what. Or am I understanding you wrong?
  12. As I mentioned I wasn't trying to do it for you, I was giving you an example.
  13. <?php include('connect.php'); class Registration { $first=$_POST['frm_first']; $last=$_POST['frm_last']; $first_lower=strtolower($first); $last_lower=strtolower($last); $user=$first . "." . $last; $pass=md5($_POST['frm_pass']); $dept=$_POST['frm_dept']; $job=$_POST['frm_job']; $email=$_POST['frm_email']; $phone=$_POST['frm_phone']; $mobile=$_POST['frm_mobile']; $qual=$_POST['frm_qual']; $errArray[] = 0; $error = 'false'; function Registration() { if(empty($_POST)) { $registration = new Registration(); $registration->displayForm(); } else { $registration->errorCheck() if($error != 'true') { $registration->registerUser(); } if($error = 'true') { $registration->displayErrors(); $registration->displayForm(); } } } function errorCheck() { if(empty($_POST['frm_first'])) { array_push($errArray, "Please specify a First name"); $error = 'true'; } if(empty($_POST['frm_last'])) { array_push($errArray, "Please specify a Lastname"); $error = 'true'; } if(empty($_POST['frm_pass'])) { array_push($errArray, "Please specify a Password"); $error = 'true'; } if(empty($_POST['frm_dept'])) { array_push($errArray, "Please specify a Department"); $error = 'true'; } if(empty($_POST['frm_job'])) { array_push($errArray, "Please specify a Job Title"); $error = 'true'; } if(empty($_POST['frm_email'])) { array_push($errArray, "Please specify an Email"); $error = 'true'; } } public function displayForm() { ?> <p>Fill in the form below with your details</p> <form class="frm" action="register.php" method="post"> First Name <input type="text" name="frm_first" maxlength="20" value="<?php echo $first ?>" /> Last Name <input type="text" name="frm_last" maxlength="20" value="<?php echo $last ?>" /> Password <input type="password" name="frm_pass" maxlength="20" value="" /> Department <select name="frm_dept"> <option value="<?php echo $dept ?>"><?php echo $dept ?></option> <option value="F1">F1</option> <option value="F2">F2</option> <option value="F3">F3</option> <option value="F4">F4</option> <option value="F5">F5</option> <option value="F6">F6</option> <option value="F7">F7</option> <option value="F8">F8</option> <option value="F9">F9</option> </select> Job Title <input type="text" name="frm_job" maxlength="40" value="<?php echo $job ?>" /> Email <input type="text" name="frm_email" maxlength="40" value="<?php echo $email ?>" /> Phone <input type="text" name="frm_phone" maxlength="15" value="<?php echo $phone ?>" /> Mobile <input type="text" name="frm_mobile" maxlength="15" value="<?php echo $mobile ?>" /> Qualifications <input type="frm_qual" name="county" maxlength="20" value="<?php echo $qual ?>" /> <input type="submit" value="Submit" /><input type="reset" value="Reset" /> </form> <a href='index.php'>Back to Main[/url] <?php } public function registerUser() { mysql_connect($sql_server,$sql_username,$sql_password); mysql_select_db($sql_database) or die( "Unable to select database"); $query = "INSERT INTO staff VALUES ('$user','$pass','$first','$last','$qual','$email','$phone','$mobile','$dept','$job','NULL','n','n');"; $result = mysql_query($query); mysql_close(); if (!$result) { array_push($errArray, "User Account Already Exists"); $error = 'true'; } else { echo "Registered $user "; echo "<a href='index.php'>Back to Main[/url] "; } } public function displayErrors() { echo "There were errors in your form: "; $count = 0; reset($errArray); foreach ($errArray as $value) { if ($count != 0) { echo "<li>" . $value . "</li>"; } $count++; } } } ?> The above has many flaws, as mentioned. One thing is you should try to seperate your presentation from your logic.
  14. Or if not then you basically answered your own question. in the constructor you would just instantiate each extension into a variable and you can have access to it that way. Look at cake/code ignitor because they have a nice way of doing it.
  15. <?php /* Registration Script*/ require ('mysql.php'); if (isset ($_POST['submit'])) { // Check to see if the form has been submitted $errorhandler = ''; if ($_POST['username'] == '') { $errorhandler .= 'username is required.<br />'; } if ($_POST['password'] == '') { $errorhandler .= 'password is required.<br />'; } if ($_POST['password'] != $_POST['password2']) { $errorhandler .= 'Passwords must match'; } if ($errorhandler != '') { echo '<span>'; echo $errorhandler; echo '</span>'; } if ($errorhandler == '') { $username = $_POST['username']; $password = md5 ($_POST['password']); // MD5 encrypt the password so it is more secure $regkey = $_POST['regkey']; // See if the key is valid $sql = "SELECT * FROM reg_keys WHERE regkey='$regkey' LIMIT 1"; if ($r = mysql_query ($sql)) { $num = mysql_num_rows ($r); if ($num > 0) { // if there is a row with that key, the key is valid // The key is valid, add user to the database $add_sql = "INSERT INTO users (users_id, username, password, regkey) VALUES (0, '$username', '$password', '$regkey')"; // We make the first value (for users_id) 0 because it is set to auto increment, // so the users_id will be assigned to the next available number if ($add_r = mysql_query ($add_sql)) { // The user successfully registered print 'Thank you for registering!'; // Delete the key from the key database, so it cannot be used again mysql_query ("DELETE FROM reg_keys WHERE regkey='$regkey'"); } else { // The user did not successfully register print 'Error:' . mysql_error(); // print the MySQL error } } else { // The key is not valid print 'The registration key you entered was not valid!'; } } else { // The regkey check query failed print 'Error:' . mysql_error(); // print the MySQL error } } } else { // The form was not submitted // Display the form print '<table height="100%" align="center" valign="center"> <td> <form action="register.php" method="post"> <table border="0"> <tr> <td align="right" style="color: #fff;">Username:</td> <td align="center"><input type="text" name="username" /></td> </tr> <tr> <td align="right" style="color: #fff;">Password:</td> <td align="center"><input type="password" name="password" /></td> </tr> <tr> <td align="right" style="color: #fff;">Confirm Password:</td> <td align="center"><input type="password" name="password2" /></td> </tr> <tr> <td align="right" style="color: #fff;">Registration Key:</td> <td align="center"><input type="text" name="regkey" /></td> </tr> <tr> <td></td> <td align="center"><input type="submit" name="submit" value="Register" /></td> </tr> </table> </form>'; } ?> I put 2 seconds into that to give you an example, base it off of that. Just reformat it, and clean it up some I was in a hurry,so I just provided a basic example.
  16. $sql="SELECT * FROM my_table where last='$query' AND first LIKE '%$first%' ORDER BY first"; Try that, post back the results.
  17. use require_once not include once. Especially if it's a file that is needed for the page to run.
  18. Your doing it the hard way. Make the select statement a value, and just grab the value (they can only select one option). <select name="whatever[]"> <option value="value 1">yep</option> <option value="value 2">Nope</option> </select> Then grab in the php $var = $_POST['whatever']; is that what you were wondering?
  19. Actually he also asked how to get them. In order to generate url's of id's of items from a db it's something like <?php $select * from users;"; $query = mysql_query($select); while ($row = mysql_fetch_array($query) { echo $row['firstname'] . '<a href="profileview.php?' . $row['id'] . '" title="user">User</a>'; } ?> That's just a quick example.
  20. paste the syntax errors sent to the browser, or the output. Not the code..
  21. It's pretty much ORDER BY whatever ASC // for ascending order ORDER BY whatever DSC // for descending I just typed that from memory and it's late so double check the syntax.
  22. To "get" the xml data use curl, rest, or soap. If you want to parse it try SimpleXML, Expat, or XMLDom. However I don't personally recommend any of the three. I recommend googling (xml->array) for php. In fact I put the data here for you. As well as an example on some stuff I did in my spare time with amazon services. XML Class <?php /* XML Parser Class by Eric Rosebrock http://www.phpfreaks.com Class originated from: kris@h3x.com AT: http://www.devdump.com/phpxml.php Usage: <?php include 'clsParseXML.php'; $xmlparse = &new ParseXML; $xml = $xmlparse->GetXMLTree('/path/to/xmlfile.xml'); echo "<pre>"; print_r($xml); echo "</pre>"; ?> The path to the XML file may be a local file or a URL. Returns the elements of the XML file into an array with it's subelements as keys and subarrays. */ class ParseXML{ function GetChildren($vals, &$i) { $children = array(); // Contains node data if (isset($vals[$i]['value'])){ $children['VALUE'] = $vals[$i]['value']; } while (++$i < count($vals)){ switch ($vals[$i]['type']){ case 'cdata': if (isset($children['VALUE'])){ $children['VALUE'] .= $vals[$i]['value']; } else { $children['VALUE'] = $vals[$i]['value']; } break; case 'complete': if (isset($vals[$i]['attributes'])) { $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($children[$vals[$i]['tag']])-1; if (isset($vals[$i]['value'])){ $children[$vals[$i]['tag']][$index]['VALUE'] = $vals[$i]['value']; } else { $children[$vals[$i]['tag']][$index]['VALUE'] = ''; } } else { if (isset($vals[$i]['value'])){ $children[$vals[$i]['tag']][]['VALUE'] = $vals[$i]['value']; } else { $children[$vals[$i]['tag']][]['VALUE'] = ''; } } break; case 'open': if (isset($vals[$i]['attributes'])) { $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($children[$vals[$i]['tag']])-1; $children[$vals[$i]['tag']][$index] = array_merge($children[$vals[$i]['tag']][$index],$this->GetChildren($vals, $i)); } else { $children[$vals[$i]['tag']][] = $this->GetChildren($vals, $i); } break; case 'close': return $children; } } } function GetXMLTree($xmlloc){ if (file_exists($xmlloc)){ $data = implode('', file($xmlloc)); } else { $fp = fopen($xmlloc,'r'); while(!feof($fp)){ $data = $data . fread($fp, 1024); } fclose($fp); } $parser = xml_parser_create('ISO-8859-1'); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); $tree = array(); $i = 0; if (isset($vals[$i]['attributes'])) { $tree[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($tree[$vals[$i]['tag']])-1; $tree[$vals[$i]['tag']][$index] = array_merge($tree[$vals[$i]['tag']][$index], $this->GetChildren($vals, $i)); } else { $tree[$vals[$i]['tag']][] = $this->GetChildren($vals, $i); } return $tree; } } Example <?php require_once("./amazon.class.php"); require_once("./xml.class.php"); // request 1 $amazon = new AmazonECS_Item; $results = $amazon->ItemSearch('psychic', 'All', 'Medium'); $fp = fopen('temp.xml', 'w'); fwrite($fp, $results); fclose($fp); $xmlparse = &new ParseXML; $xml = $xmlparse->GetXMLTree('temp.xml'); // second request $amazon = new AmazonECS_Item; $results = $amazon->ItemSearch('paranormal', 'All', 'Medium'); $fp = fopen('temp.xml', 'w'); fwrite($fp, $results); fclose($fp); $xmlparse = &new ParseXML; $xml2 = $xmlparse->GetXMLTree('temp.xml'); //echo '<pre>'; //echo print_r($xml); //echo '</pre>'; //exit; ?> After that you'll have yourself an array that's easier than straight parsing xml.
  23. <?php switch ($total) { case $total>18.50: echo "Your Body Mass Index is"; printf ('%01.2f',$total); echo "%"; echo "You are Normal Weight, give yourself a pat on the back!"; break; case $total<18.50: echo "Your Body Mass Index is"; printf ('%01.2f',$total); echo "%"; echo "You are Currently Underweight This is not healthy"; break; case $total<25: echo Your Body Mass Index is"; printf ('%01.2f',$total); echo "%"; echo "You are Normal Weight, give yourself a pat on the back!"; break; case $total>25: echo "Your Body Mass Index is"; printf ('%01.2f',$total); echo "%"; echo "You are Over Weight, Get to Exercizing on a Daily Basis!"; break; case $total>30: echo "Your Body Mass Index is"; printf ('%01.2f',$total); echo "%"; echo "You are Over Weight, Get to Exercizing on a Daily Basis! Consult a Doctor ASAP!"; break; } ?> Try that, if not paste your EXACT errors.
  24. <?php $email = $_POST['email']; // don't forget to clean it foreach($email as $k=>$v) { // run query } ?> <form name="signup" id="signup" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input name="email[]" (name them this and do whatever you do to replicate them) </form>
×
×
  • 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.