
Drummin
Members-
Posts
1,004 -
Joined
-
Last visited
Everything posted by Drummin
-
Have you echoed out the session to see if it's being set?
-
You need to use table fields as in $sql="SELECT UsersID,U_YearID FROM users WHERE UsersID='$UsersID' and U_Password='$U_Password'"; NOT $sql="SELECT * FROM users WHERE UsersID='$UsersID' and U_Password='$U_Password'";
-
Have you checked that session is being set? If not try this. if($count==1){ // Register $UsersID, $U_Password and redirect to file "login_success.php" $_SESSION['UsersID']=$result[0]; $_SESSION['U_YearID']=$result[1]; if($_SESSION['U_YearID']==1){ // header("location:login_success.php"); // exit; } if($_SESSION['U_YearID']==2){ // header("location:login_success2.php"); // exit; } if($_SESSION['U_YearID']==4){ // header("location:login_success4.php"); // exit; } echo "$_SESSION[u_YearID]"; } else { echo "Wrong Username or Password"; } If you are getting results as expected with values being echoed (1, 2 or 4) then try this code. Brackets added around IF statements with exit added. if($count==1){ // Register $UsersID, $U_Password and redirect to file "login_success.php" $_SESSION['UsersID']=$result[0]; $_SESSION['U_YearID']=$result[1]; if($_SESSION['U_YearID']==1){ header("location:login_success.php"); exit; } if($_SESSION['U_YearID']==2){ header("location:login_success2.php"); exit; } if($_SESSION['U_YearID']==4){ header("location:login_success4.php"); exit; } } else { echo "Wrong Username or Password"; }
-
Not sure if this is what you're looking for. $bytes = 1522265; $Mbytes = $bytes/1024; $Mbytes = number_format($Mbytes, 2, '.', '');
-
As Pikachu2000 pointed out, you can't send anything to the browser before setting any sessions. This includes echoing out the $sql. Comment out that line or remove it.
-
I don't know about this error but it seems like it might be a htaccess issue or related to the version of php you are using.
-
U_YearID is plain text and not defined as string and when comparing two values use two == signs. The code posted is not tested and assumes U_YearID is a table field in your users table. <?php session_start(); $host="localhost"; // Host name $username="phpuser"; // username $password="phpuser"; // password $db_name="phpsite"; // Database name $tbl_name="users"; // Table name // Replace database connect functions depending on database you are using. mysql_connect("$host", "$username", "$password"); mysql_select_db("$db_name"); //submitting query // username and password sent from form //NEVER Remove the mysql_real_escape_string. Else there could be an Sql-Injection! $UsersID=mysql_real_escape_string($_POST['UsersID']); $U_Password=mysql_real_escape_string($_POST['U_Password']); $sql="SELECT UsersID,U_YearID FROM users WHERE UsersID='$UsersID' and U_Password='$U_Password'"; $result=mysql_query($sql); //checking results // Replace counting function based on database you are using. $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row //Direct Userbased on result if($count==1){ // Register $UsersID, $U_Password and redirect to file "login_success.php" $_SESSION['UsersID']=$result[0]; $_SESSION['U_YearID']=$result[1]; if($_SESSION['U_YearID']==1) header("location:login_success.php"); if($_SESSION['U_YearID']==2) header("location:login_success2.php"); if($_SESSION['U_YearID']==4) header("location:login_success4.php"); } else { echo "Wrong Username or Password"; } ?>
-
Is there any space or line returns before <?php at the top of the page?
-
I wouldn't save a password to session. As far as your question, where you have the header going to login_success.php, just check the user level and based on this, send the user to appropriate page with the header. A few simple IF statements should do the job.
-
Assuming it was working when form processing was in body, can you keep form processing in body and reload page with header redirect?
-
OK... while you posted that I was typing... Glad you got it working. <?php //include the S3 class require_once('sdk-1.4.4/sdk.class.php'); // Instantiate the class $imageforms=""; $s3 = new AmazonS3(); $response = $s3->get_object_list('bucket', array('prefix' => $id.'/')); $o=0; foreach ($response as $file){ $furl = "http://quizfox.s3.amazonaws.com/".$file; //output a link to the file $imageforms.="<img src='$furl' width='50' />$furl"; $imageforms.="<form action=\"/s3processdelete.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"form2\" id=\"form2\"> <input type=\"hidden\" name=\"file\" value=\"$file\" /> <input name=\"SubmitDelete\" type=\"submit\" class=\"delete\" value=\"Delete This Image\" /> </form>"; $o=$o+1; } ?> <html> <body> <?php echo "$imageforms"; ?> </body> </html>
-
Anyway you can put the "code that runs and produces a variable ($i)" higher on the page? Not knowing what you're doing, I would say, run this above the html part of the page, and display what's needed for each section. Any "POST update" code should also be above this as well.
-
help needed pulling text links into a navigation. please
Drummin replied to ricky spires's topic in PHP Coding Help
This is a php forum. What have you tried? Can you make database connection? Most people will help you debug code and are more than happy to point out errors (not that that's any fun) but you should a least try. -
re-executing mysql query after submission - two forms one page
Drummin replied to nomis's topic in PHP Coding Help
Have POST processing above html and the query should reload fresh as the page loads. -
Yes but as you know adding isset() will stop undefined index errors and the second check could be any number of things related to the session like $_SESSION['loggedIn'] == "Banned". But you are right, if it's TRUE then it's SET.
-
At the top of your new page add... <?PHP session_start(); $idCliente=$_SESSION["idCliente"]; //Then user variable for queries etc.
-
Several of your "checks" were not being processed. See if this helps. <?php if(isset($_POST['submit'])){ $target = "images/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; $uploaded_size=($_FILES['uploaded']['size']); //This is our size condition. Many hosts limit to 2mb by default if ($uploaded_size > 2000000) { echo "Your file is too large.<br>"; $ok=0; } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $uploaded_type=getExtension($_FILES['uploaded']['name']); //This is our limit file type condition if ($uploaded_type =="php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $ok=2; echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; } else { $ok=0; echo "Sorry, there was a problem uploading your file."; } } }//if(isset($_POST['submit'])) if($ok==1){echo "Size Limit 2mb";} ?> <form enctype="multipart/form-data" action="uploader.php" method="post"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" name="submit" value="Upload" /> </form>
-
foreach($mods as $key => $value) { if ($value['goauld'] == $_POST['name_list'] ) { echo '<option value="' . $value['goauld'] . '" selected="selected"> ' . $value['goauld'] . '</options>'; } else{ echo '<option value="' . $value['goauld'] . '"> ' . $value['goauld'] . '</options>'; } }
-
No more than 14 and no less than 5 charactars is always given
Drummin replied to MrCostari's topic in PHP Coding Help
EDIT: SergeiSS' pointed out the real issue with a post inside a get. The code/form directing to this page might help. -
Are you using both $searchWord and $searchTerm?
-
Where is $cours['nom'] defined?
-
You can also set a session value after posted values pass and have this as part of your initial processing check. This would also allow you to hide the form or show a message on another page it you wish. Refreshing page will not update DB again. if(isset($_POST['save']) && !isset($_SESSION['showform'])){ //form check code //If values pass session_start(); $_SESSION['showform']="f"; //add you insert code }
-
I suppose a simple IF comparison to the posted color would work instead of the strpos(), but you get the idea.
-
strpos() will give you a pretty quick result if string is in a string. I based this example off your last post and added a color selection box. <?php //colors array for selection $colors = array('red','black','pink'); //$colors = implode($colors); $tagArr = array('car' => array('red','black'),'boat' => array('red','black'),'boat' => array('black','pink'),'bike' => array('red')); if(isset($_POST['submit']) && !empty($_POST['color'])){ $turms=""; foreach($tagArr as $field => $values){ foreach($values as $value){ $found=strpos($_POST['color'],$value); if ($found !== false){ $turms.="$field='$value'"; $turms.=" OR "; } } } if(!empty($turms)){ $turms = substr($turms,0,-4); echo "$turms"; //$makeQuery = mysql_query("SELECT * FROM points_tags WHERE $turms"); } } echo "<form method=\"post\" action=\"\">\n"; echo "<select name=\"color\" />\n"; echo "<option value=''>-----</option>\n"; foreach($colors as $key => $color){ echo "<option value='$color'>$color</option>\n"; } echo "</select>\n"; echo "<input type=\"submit\" name=\"submit\" value=\"Search\" />\n"; echo "</form>\n"; ?>
-
<?php if(isset($_POST['delete'])) { // this is a check box you need to check in order to confirm if(empty($_POST['confirm'])){ echo "You need to check confirm"; }else{ mysql_query("DELETE FROM `users` WHERE `goauld`= '".mysql_real_escape_string($_POST['gd'])."'"); mysql_query("DELETE FROM `users` WHERE `goauld`= '".mysql_real_escape_string($_POST['gd'])."'"); echo "$delete_goauld was deleted<br />\n"; } } ?>