Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. To redirect them, use this code header('Location: page.html');
  2. Sounds like an HTML problem, not PHP.
  3. You never closed the brackets for this IF statement. if (@is_array($errors)) { Here is a better visual of your code, just to make it easier to read <?php /*program: login.php desc: login program for the Locker Room section of lapgrinder. It provides two options: (1) login using an existing Login Name and (2) enter a new login name. Login Names and passwords are stored in a MySQL database. */ session_start(); include("shoes.inc"); switch (@$_POST['do']) { case "login": $cxn = mysql_connect($host, $user, $password, $dbname) or die("Couldn't connect to server."); $sql = "SELECT loginName FROM Member WHERE loginName='$_POST[fusername]'"; $result = mysql_query($cxn,$sql) or die("Couldn't execute query."); $num = mysql_num_rows($result); if($num > 0) // login name was found { $sql= "SELECT loginName FROM Member WHERE loginName='$_POST[fusername]' AND password=md5('$_POST[fpassword]')"; $result2 = mysql_query($cxn,$sql) or die("Couldn't execute query 2."); $num2 = mysql_num_rows($result2); if($num2 > 0) //password is correct { $_SESSION['auth']="yes"; $logname=$_POST['fusername']; $_SESSION['logname'] = $logname; $today = date("Y-m-d h:i:s"); $sql = "INSERT INTO Login (loginNam, loginTime) VALUES ('$logname','$today')"; $result = mysql_query($cxn,$sql) or die("can't excute insert query."); header("location: Member_page.php"); } else //password is not correct { $message="The Login Name or password is not correct! Please try again!. "; include("lockerroomlogin.php"); } } else if($num == 0) //login name not found { $message = "The Login Name you entered does not exist! Please try again. "; include("lockerroomlogin.php"); } break; case "new": /* Check for blanks */ foreach($_POST as $field => $value) { if ($field != "fax") { if ($value == "") { $blanks[] = $field; } } } if (isset($blanks)) { $message_new = "The following fields are blank. Please enter the required information: "; foreach($blanks as $value) { $message_new .= "$value, "; } extract($_POST); include("lockerroomlogin.php"); exit(); } /*Validate data*/ foreach($_POST as $field => $value) { if (!empty($value)) { if (eregi("name",$field) and !eregi("login",$field)) { if (!ereg("^[A-Za-z' -]{1,50}",$value)) { $errors[]="$value is not a valid name."; } } if (eregi("state",$field) or eregi("city",$field)) { if (!ereg("^[A-Za-z]{2,50}",$value)) { $errors[] = "$value is not a valid city or state."; } } if (eregi("email",$field)) { if (!ereg("^.+@.+\\..+$",$value)) { $errors[] = "$value is not a valid email address."; } } } // end if empty } // end foreach if (@is_array($errors)) { $message_new =""; foreach($errors as $value) { $message_new .= $value."Please try again "; } extract($_POST); include("lockerroomlogin.php"); exit(); /*clean data*/ $cxn = mysql_connect($host,$user,$passwd,$dbname); foreach($_POST as $field => $value) { if ($field != "button" and $field != "do") { if ($field == "password") { $password = strip_tags(trim($value)); } else { $fields[]=$field; $value = strip_tags(trim($value)); $values[] = mysql_real_escape_string($cxn,$value); $$field = $value; } } } /*check whether user name already exists*/ $sql = "SELECT loginName FROM Member WHERE loginName = '$loginName'"; $result = mysql_query($cxn,$sql) or die("Couldn't execute select query."); $num = mysql_num_rows($result); if ($num > 0) { $message_new = "$loginName already in use. Please select another name."; include("lockerroomlogin.php"); exit(); } /*Add a new member to database*/ else { $today = date("Y-m-d"); $fields_str = implode(",",$fields); $values_str = implode('","',$values); $fields_str .=",createDate"; $values_str .='"'.",".'"'.$today; $fields_str .=",password"; $values_str .='"'.","."md5"."('".$password."')"; $sql = "INSERT INTO Member "; $sql .= "(".$fields_str.")"; $sql .= " VALUES "; $sql .= "(".'"'.$values_str.")"; $result = mysql_query($cxn,$sql) or die("Couldn't execute insert query."); $_SESSION['auth']="yes"; $_SESSION['logname'] = $loginName; /*send and e-mail to new member*/ $emess = "A new member account has been set up. "; $emess.= "Your new Member ID and password are:"; $emess.= "\n\n\t$loginName\n\t$password\n\n"; $emess.="We appreciate you joinging Lapgrinder.com and the Locker Room"; $emess.="If you have any questions or problems, email grindersupport@lapgrinder.com"; $ehead="From: contact@lapgrinder.com\r\n"; $subj = "Your Locker Room Login Information"; $mailsnd=mail("$email","$subj","$emess","$ehead"); header("location:new_member.php"); } break; default: include("lockerroomlogin.php"); } ?> Note, I didn't close that bracket for you.
  4. I just found this, should be exactly what you want http://javascript.internet.com/forms/limit-textarea.html
  5. This would have to be done with JavaScript.
  6. I'm pretty sure that mysql_num_rows will echo out 1 even if there isn't any rows. I would go physically check the database.
  7. Are you sure there are any rows in your comicArt table?
  8. I completely took your question the wrong way. Sorry about that, just disregard my previous posts.
  9. I moved the code that checks if they pressed submit above the form. Then I added an exit so that the form below wouldn't show when the submit button was pressed. Did you try it?
  10. <?php $query = "SELECT COUNT(*) FROM table WHERE Member1='e'"; $result = mysql_query($query)or die(mysql_error()); $num = mysql_num_rows($result); echo "$num results returned"; ?>
  11. global will make the variable in scope for the function. If you did this <?php $first = "blah"; function whatever(){ echo $first; } ?> The $first var wouldn't be echoed in the function because it is out of scope. So you would have to do what you did in your example. http://us.php.net/global
  12. Case is used in a switch statement. You can read more about that here www.php.net/switch Break is used to stop the execution of a loop http://us2.php.net/break Classes are a huge topic. You can learn about them here http://us.php.net/class Or there are plenty of tutorials on the internet.
  13. Try <?php ob_start(); //output buffering begin session_start(); include 'config.php'; include 'opendb.php'; echo "<h1>Place Bet3</h1>"; echo "</br>Mode: ".$_SESSION['mode']; echo "</br>Category: ".$_SESSION['category']; echo "</br>Date:".$_SESSION['date']; //echo "<table border=1>"; //display all the data inside result table //$result=mysql_query("SELECT DrawDate,DrawNumber,Category FROM result") or die('Query failed: ' . mysql_error()); //while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { //echo "<tr><td>$row[DrawDate]</td><td>$row[DrawNumber]</td><td>$row[Category]</td></tr>"; //} //echo "</table>"; //finding the drawnumber.. $result=mysql_query("SELECT DrawDate,DrawNumber,Category FROM result") or die('Query failed: ' . mysql_error()); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { if(($row[DrawDate]==$_SESSION['date'])&&($row[Category]==$_SESSION[category])){ $_SESSION[drawnumber]=$row[DrawNumber]; echo "</br>DrawNumber=".$_SESSION[drawnumber]; } } if(isset($_POST['bet'])){ $_SESSION['betnumber']=$_POST[betnumber]; $_SESSION['amount']=$_POST[amount]; echo "bet"; [color=red] header ('Refresh:2;url=placebet4.php'); echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>you will be redirected into Confirm page in 2 seconds</font></td></tr></table></center>";[/color] ob_flush(); //$sql="INSERT INTO transaction (DrawNumber,Amount,PurchaseNo,BetMode) //VALUES ('$drawnumber','$_POST[amount]','$_POST[betnumber]','$_SESSION[mode]')"; //mysql_query($sql, $con); exit; } ?> <html> <table> <form action=placebet3.php method='post'> </br> Betting Number <input type=text name=betnumber> </br> Amount (RM) <input type=text name=amount> </br> <input type=submit name=bet value=Bet> </form> </table> </html>
  14. No it won't, it will give you the name of the script along with it's extension.
  15. And for your second question, yes...you will have to pass the variable as a parameter of the function.
  16. $_SERVER['PHP_SELF'] Will return the files name.
  17. Change this line: <select name="number">"; To <select name='number'>";
  18. Try changing your search variable to this: $search = '4711'; It may be reading the number as a string inside the array, so making it a string in the variable may work.
  19. if ($type == "true" { To if ($type == "true") { You need to tell us what the script should do and whats not working, and give us any error messages you may be getting.
  20. You never actually perform a mysql_query(), you just set it up. <?php $sql_num = "SELECT * FROM jobs WHERE (country='$targetb' OR continent='$targetb') AND (type='$type' OR alltype='$type') $keys"; $result = mysql_query($sql_num)or die(mysql_error()); //<---You need this line $num = mysql_num_rows($result); ?>
  21. Okay, here is some code I put together that has none of your formatting in it...but I am just trying to get your desired results for now. <?php $query = "SELECT t.cat_name, t.cat_id FROM tag_category t INNER JOIN tags ON tags.cat_id = t.cat_id"; $result = mysql_query($query)or die(mysql_error()); while ($category = mysql_fetch_assoc($result)){ echo "The </b>{$category['cat_name']}</b> category<br>"; $get_tags = "SELECT * FROM tags WHERE cat_id='{$category['cat_id']}'"; $tags = mysql_query($get_tags)or die(mysql_error()); while ($tag = mysql_fetch_assoc($tags)){ echo $tag['tag_name'].', '; } echo '<p>'; } ?> See if thats what you want. If there is something wrong with it, it has to be that first query in the code...I'm not completely positive thats how you would do it...I think it is though.
  22. Ah, sorry...I guess you need the cat_id as well. Just add it to the query $query = "SELECT t.cat_name, t.cat_id FROM tag_cat t INNER JOIN tags ON tags.cat_id = t.cat_id";
  23. I see you have an error on the page now that says Unknown table 'tag_category' in on clause I think I saw in your previous code that the table was actually named "tag_categories", so just change this $query = "SELECT t.cat_name FROM tag_cat t INNER JOIN tags ON tags.cat_id = t.cat_id"; To $query = "SELECT t.cat_name FROM tag_categories t INNER JOIN tags ON tags.cat_id = t.cat_id"; Or if "tag_categories" isn't the name either, just change it to whatever it is.
  24. Give this a try <?php $query = "SELECT t.cat_name FROM tag_cat t INNER JOIN tags ON tags.cat_id = t.cat_id"; $select_tags_query = mysql_query($query)or die(mysql_error()); while ($tag_category = mysql_fetch_assoc($select_tags_query)) { $tags_query = mysql_query('SELECT * FROM `tags` WHERE `cat_id` = ' . $tag_category['cat_id'] . ''); echo '<div class="tag_cat">'; //renders out the category name echo '<h3>' . $tag_category['cat_name'] . '</h3>'; //renders out each tag in the category while ($tags = mysql_fetch_assoc($tags_query)) { echo '<p class="tag_check"><a href="search.php?tag=' . $tags['tag_id'] . '">'. $tags['tag_name'] .'</a></p>'; } } echo '</div> <!-- tag_cat div -->'; ?>
  25. It already looks like you have it put into a table...whats the problem?
×
×
  • 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.