Jump to content

benjaminbeazy

Members
  • Posts

    460
  • Joined

  • Last visited

    Never

Everything posted by benjaminbeazy

  1. hey... when i started this post, I was makin under 30k. Got a new gig now makin' over 60!
  2. hope this gives you a better understanding and some place to start. if(isset($_GET['page']) && !empty($_GET['page'])){ $page = $_GET['page']; }else{ //no page provided in url, use your home page $page = 'home'; } //list of acceptable pages $pages = array('about','home','contact'); //check to see if user is admin. if so add admin pages // this assumes checklogin returns true when user is admin // modify as needed... if(checklogin()){ array_push($pages, 'restrictedpage1','restrictedpage2'); } //include your header here //see if $page is acceptable. if not show an error page if(in_array($page,$pages)){ include('/path/to/includes/'.$page.'.php'); }else{ include('/path/to/includes/error_page.php'); } //include your footer here
  3. use a frontend controller and do your access checks before including page specific scripts. or a simple die('Ur haxoring me!'); on false...
  4. you should be able to just tack on shipping_costs to you select..
  5. you cant use header() to redirect after any output, unless you turn on output buffering..
  6. your problem is variable scope.... you can't access global variables inside functions unless declaring them in the function or passing them to the function. so you could either do this.... (passing vars) function get_news($mysql_server, $username, $password, $database) {... and call the function like... get_news($mysql_server, $username, $password, $database); or this (declaring globals) function get_news() { global $mysql_server, $username, $password, $database; ...
  7. your update query will update all records if you don't have where clause. it should be something like... if ( !$cx->query( "UPDATE $table SET price = '$price' WHERE id=$id")
  8. that's too much code for me to look through. inside your while (!feof($fp)), throw in a $var = time(); and test it against the start time of the read, if its greater than however many seconds: throw a notice of some sort and..... here it is: break;
  9. move_uploaded_file($_FILES["NAME_OF_FILE_FIELD_IN_YOUR_FORM"]["tmp_name"], "upload/" . $somename);
  10. try this... var end = int(month.site.value) + 100;
  11. try this... <?php require("connect.php"); $username = $_POST['user']; $password = sha1($_POST['pass']); $password2 = sha1($_POST['pass2']); $email = $_POST['email']; function error() { if(!$query) { echo "Query Failed: " . mysql_errno() . '<br />' . mysql_error(); } } function exist() { global $result; $num_rows = mysql_num_rows($result); if($num_rows<=0) { die('No Username in database'); } elseif($num_rows>1) { die('Cannot enter more then one username!'); } } function check() { global $result; mysql_select_db("divnx5_web"); $result = "SELECT `username` FROM `users` WHERE `username` = '$username'"; $error = mysql_query($result) OR die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "The username " . $username . 'is already taken!'; } } if(!$con) { echo "<br /><br />Registering is disabled right now, please check back later."; } else { if(!$_POST['register']) { echo "<br /><br />Use the following form to register a new account with us. <form action='register.php' method='post'><br /><br /> <font size='2'>Username:</font><br /> <input type='text' id='user' name='user' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /> <font size='2'>Password:</font><br /> <input type='password' id='pass' name='pass' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /> <font size='2'>Confirm Password:</font><br /> <input type='password' id='pass2' name='pass2' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /> <font size='2'>E-mail Address:</font><br /> <input type='text' id='email' name='email' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /><br /> <input type='submit' name='register' id='register' value='Register' style='background-color: #FFFFFF; color: #000000; font-size: 8pt; border: 1 solid #003399' /> <input type='reset' value='Clear' style='background-color: #FFFFFF; color: #000000; font-size: 8pt; border: 1 solid #003399' /> </form>"; } else { if(!$username) echo "The username you entered encountered a problem.<br /><br />"; exist(); check(); if(!$password || !$password2) echo "The password field cannot be left empty!<br /><br />"; if(!$email) echo "The email you entered encountered a problem.<br /><br />"; if($password != $password2) echo "The passwords you entered do not match.<br /><br />"; else { mysql_select_db("divnx5_web"); mysql_query("INSERT INTO users(username, password, email) VALUES('$username', '$password', '$email')"); error(); mysql_close($con); echo "Thank you for registering with us " . $username . '! Enjoy your stay!'; } } } ?>
  12. no prob. remember whenever you post to a script through a form that you have to declare the variables as $var = $_POST['var'] or something similar
  13. try this... <?php if ($_POST['searching'] == "yes") { echo "<h2>Results</h2><p>"; $find = $_POST['find']; $field = $_POST['field']; if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } mysql_connect("xxxxxxxxx", "xxxxx", "xxxxx") or die(mysql_error()); mysql_select_db("xxxxx") or die(mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { echo $result['first_name']; echo " "; echo $result['last_name']; echo "<br>"; echo "<br>"; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } echo "<b>Searched For:</b> " .$find; } ?> <h2>Search</h2> <form name="search" method="post" action="<?=$_SERVER['PHP_SELF']?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="first_name">First Name</option> <Option VALUE="last_name">Last Name</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form>
  14. i certainly agree, but to each his own...
  15. try throwing \r\n after emailaddress
  16. pagination my friend... this isnt perfect but u get the idea <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ( $file != "." && $file != ".." ) { //replace the strings on the filename so we can generate clean title attributes //and clean anchor text. $files[$i]['file'] = $file; $file2 = str_replace("-", " ", $file); $files[$i]['file2'] = str_replace(".php", "", $file2); $file3 = str_replace("san jose", "", $files[$i]['file2']); $i++; } } closedir($handle); } if(!empty($_GET['offset'])){ $offset = $_GET['offset']; }else{ $offset = 0; } for($i=$offset;$i<($offset+10);$i++){ echo '<li><a href="'.$files[$i]['file'].'" title="'.$files[$i]['file2'].'">'.$files[$i]['file3'].'</a></li> '; echo "\n"; } echo '<br><br>'; if($offset>9){ echo '<a href="?offset=' . $offset-10 . '">PREV</a>'; } if(count($files) >= ($offset+1)){ echo '<a href="?offset=' . $offset+10 . '">NEXT</a>'; } ?>
  17. it's a little link on the top or bottom of the thread that says topic solved. just search for it on the page (ctrl+f) until u find it.
  18. there are methods you could use, but they are rather complex to try and accomplish this...
  19. doesn't make a difference though really. javascript is client-side. no matter how you slice, the user can see javascript. whether its a different file or directly on the page.
  20. the max size will most likely be whatever the script memory_limit is. from what i gather, that sounds like what you want to do. problem is, the session wont last forever so if you want the user's settings to be saved, you'd have to write it back to the db at some point....
  21. yes it will prevent the script from being able to call it.. u cant keep javascript private because it is client-side. the browser must have js enabled and be able to interpret it.... you can make it rather obscure if u really want to. best bet is not to put anything in js that you dont want ppl to see.
  22. add another parenthesis at the end of your long if statement.
  23. <?php $sql = "SELECT * FROM `test_results`"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $test_results[$row['member_id']][$row['test_id']][] = $row; } $sql = "SELECT * FROM `member_table` SORT BY `member_lname` ASC, `member_fname` ASC"; $result = mysql_query($sql) or die(mysql_error()); ?> <table> <tr> <td>Member</td> <?php while($row = mysql_fetch_array($result)){ $members[] = $row; echo "<td>$row['member_lname'], $row['member_fname']</td>"; } ?> </tr> <tr><td>test1</td> <? foreach($members as $val){ echo "<td>$test_results[$members[$val]['member_id']][1]['test_score']</td> <td>$test_results[$members[$val]['member_id']][2]['test_score']</td> <td>$test_results[$members[$val]['member_id']][3]['test_score']</td> <td>$test_results[$members[$val]['member_id']][4]['test_score']</td> <td>$test_results[$members[$val]['member_id']][5]['test_score']</td>"; } thats really ugly but it should work.. im tired..
×
×
  • 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.