PHP - Echo Shows On When It Shouldnt
Hey all. I have a simple code for verifying some data. I have two echos from if statements. The first is if the text input is empty echo: HELLO. The second is if text input data is not found in database echo: NOPE.
Now in the following code the second one works fine. But the problem is if I leave the field empty BOTH echos show. So if I leave the input empty instead of saying "HELLO" it says, "HELLONOPE". Yet the second one works fine and display only "NOPE" The other thing is if I switch the two echos to die instead, they work fine. Code: [Select] if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['id']) { echo "HELLO"; } // checks it against the database $check = mysql_query("SELECT * FROM emp WHERE id = '".$_POST['id']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { echo "NOPE"; } else { //if login good then redirect them to the members area $id = $_POST['id']; header("Location: somepage.php?id=$id"); } } else { // they are not logged in } <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <input type="text" name="id" maxlength="40"> <input type="submit" name="submit" value="Login"> </form> What am I doing wrong? Similar TutorialsI have peice of code which is designed enter a question into a database and the username of the person who asks the question. However, the code enters <?php echo Array; ?> into the database and not 'Tom'. I am using the same code which inserts the category of the question in the database which works. But the username comes up as <?php echo Array; ?>. Does anyone know why it shows "array"? Code: [Select] if($loggedIn) { echo "Welcome, ".$user['username'].". <a href=\"logout.php\">Logout</a>. <table width='300' border='0' align='center' cellpadding='0' cellspacing='1'> <tr> <td><form name='form1' method='post' action='phpviewquestion.php'> <table width='100%' border='0' cellspacing='1' cellpadding='3'> <tr> <td colspan='3'><strong>Your Question</strong></td> </tr> <tr> <td width='71'>Question</td> <td width='6'>:</td> <td width='600' height='50'><input name='question' type='text' id='question'></td> <td width='71'>Notes</td> <td width='6'>:</td> <td width='600' height='50'><input name='notes' type='text' id='notes'></td> </tr> <tr> <td colspan='3' align='center'><input type='image' name='image' value='Submit' src='http://www.domain.co.uk/images/submitbutton.PNG' name='image' width='100' height='53'></td> <input name='category' type='hidden' value='Furniture' id='category' > <input name='questionmaker' type='hidden' value='<?php echo $username; ?>' id='questionmaker' > </tr> </table> </form> </td> </tr> </table> </div> " ; } else { echo "Please <a href=\"login.php\">Login</a>."; } ?> Need help with some whiles, etc., and .php page refreshes. $num; Comes from mysql_num_rows from a database table's regular 'select'. And gets the row id numbers for every row that the id numbers are listed in order. $totalrows comes from another select but is select * instead. And pulls the total rows in the whole table instead there are 49 rows in the whole table. I'm trying to get the page to show 5 table rows at a time like the following, but then when the page is still open on next page refresh to show the next 5 rows and continue that way. This following: Quote PHP Code: <?php $i=$num; if ($num == 5); {echo "The number is " . $num . "<br />";} do {$i = $i + 5; echo "The number is " . $i . "<br />"; } while ($i<$totalrows); ?> Brings up these results: The row number is 10 The row number is 15 The row number is 20 The row number is 25 The row number is 30 The row number is 35 The row number is 40 The row number is 45 The row number is 50 Shows all these on the page at the same time. I'm trying to get these to only show the 5 rows after every page refresh instead. Please let me know how to do that, and whether it can be done without any cookies. I don't know if there is a better way to show the first 5 separate like I have it. Thank you very much for your help.
<?php Hi all, I have a simple upload form which is just to upload an image to a folder, this all works fine apart from one bit, once the image has been submitted then a box appears thanking the user for their upload and a close box link, then the original form also appears! I dont want this to appear once I file has been uploaded. I thought my below code would achieve that with an if statement but it is not working: <?php session_start(); $user_id = $_SESSION['user_id']; if (file_exists($user_id.'.'.$extension)) { define ("MAX_SIZE","100"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $image_name=$user_id.'.'.$extension; $newname="romimages/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} if(isset($_POST['Submit']) && !$errors) { ?> <link href="../Styles/form_dark.css" rel="stylesheet" type="text/css" /> <form class="dark" action="" method="post" > <ol> <li> <fieldset> <legend>Rom Logo Uploaded!</legend> <p> </p> <ol> <li> <label for="">Your image has been uploaded, you can now close this window</label> </li> </ol> </fieldset> </li> </ol> <br> <input type="submit" value="Close" name="submit" onClick="return parent.parent.GB_hide()" > </p> </form> <?php } } else { ?> <link href="../Styles/form_dark.css" rel="stylesheet" type="text/css" /> <form method="post" enctype="multipart/form-data" action="" class="dark"> <ol> <li> <input type="file" name="image" width="45px"> </li><br> <br> <li> <input name="Submit" type="submit" value="Upload image"> </form> <?php } ?> thanks I am probably making a dumb mistake...but heres the code... $gif = '.gif'; $jpg = '.jpg'; $jpeg = '.jpeg'; $png = '.png'; $jpeg1 = 'jpeg'; $gif1 = 'gif'; $jpg1 = 'jpg'; $png1 = 'png'; $max_file_size = '1048576'; $new_avatar = $_FILES['uploaded_avatar']['name']; $avatar_ext = end(explode('.', $new_avatar)); if (isset($_POST['change_submit1'])) { if ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } elseif ($_POST['change_box1'] != 'CHANGE') { echo 'You must fill in the "CHANGE" box!'; } elseif (($uploaded_a_file == '1') && ($avatar_ext != $jpg1) && ($avatar_ext != $png1) && ($avatar_ext != $gif1) && ($avatar_ext != $jpeg1)) { echo 'File format not supported!'; } elseif ($uploaded_a_file != '1') { echo 'No file selected!'; } elseif ($_FILES["uploaded_avatar"]["size"] > $max_file_size) { echo 'File is too big!'; } } this is the code that should be echoing my avatar upload errors. Ive checked all the if statements ive changed the order around. still nothing. all of them work other than file format not supported. I can get this one to work...but at the cost of no file selected not working...help! OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? Hi I have deleted quite lot data from mysql database however, php still shows that page but blank ie page.php?id=186 - this id and all assosiated fields with this id has been removed from mysql but id still showing on the net and google cached all of them ( 600 pages) . page.php is still in use but I was wondering if there is any way not to show these blank pages/ids from mysql db and more importantly how can I remove these blank pages from google? Thanks for your help. I'm a bit stumped here and as usual I'm sure it's something simple. I have an object that checks if a user is an admin. It works fine. But it the HTML below it is not getting displayed. Take a look. welcome.php session_start(); $user = new users(); if (!isset($_SESSION['username'], $_SESSION['imadmin']) || $user->is_admin($_SESSION['username'])==0) { header('Location: index.php'); } welcome.php is getting displayed without getting redirected to the index. But there's no HTML, just the URL to welcome.php in the bar. Anyone? Cheers! I have a database where I have 2 departments, and I want it to not show if they are both taken, but I'm not sure how to do this? Currently I have Code: [Select] $type_sql2 = mssql_query("SELECT * FROM Database2 Where SaleID ='$salesid'"); while($RS2 = mssql_fetch_assoc($type_sql2)) { $used_dist = $RS2['DistID']; $type_sql = mssql_query("SELECT * FROM Database Where Disable = 0 AND DeptID!= '$used_dist'"); while($RS = mssql_fetch_assoc($type_sql)) { $DeptID_ID = $RS['DeptID']; $DeptID_Name = $RS['DeptDescription']; echo "<option value=\"$DeptID_ID\">$DeptID_Name</option>\n"; } }And my DeptID is SE and CM, now in another database where these are used, I want this to not show them if they are both used and only show the one not being used any other time, but I can't just do it one at a time, because I may have more departments later on, but right now, with the above, if one is used, then it works, because only one shows up, but if both are used, it shows both still because it then sees SE and puts in CM, then loops thru again and sees CM and puts in SE then the second time. I hope this makes sence. But how do I not show either if both are used, and if one is used then only show the other? Thanks I try to adjust my date and time to ("M-d-Y h:i:s A"), but when I do, I get 0's for the both the date and time. Code: [Select] <table width="400" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td><strong>Test Sign Guestbook </strong></td> </tr> </table> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="addguestbook.php"> <td> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><input name="name" type="text" id="name" size="40" /></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email" size="40" /></td> </tr> <tr> <td valign="top">Comment</td> <td valign="top">:</td> <td><textarea name="comment" cols="40" rows="3" id="comment"></textarea></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table> <table width="400" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td><strong><a href="viewguestbook.php">View Guestbook</a> </strong></td> </tr> </table> Code: [Select] <?php $mysql_host = "myhost"; $mysql_database = "guest"; $mysql_user = "myusername"; $mysql_password = "mypassword"; //$db_name="guest"; This is not needed, as db_name is $mysql_database above, so please delete this line. $tbl_name="guestbook"; // Table name // Connect to server and select database. mysql_connect("$mysql_host", "$mysql_user", "$mysql_password") or die("cannot connect server "); mysql_select_db("$mysql_database") or die("cannot select DB"); $name = $_POST['name']; $email = $_POST['email']; $comment = $_POST['comment']; $datetime=date("y-m-d h:i:s"); //date time $sql="INSERT INTO $tbl_name (name, email, comment, datetime) VALUES ('$name', '$email', '$comment', '$datetime')"; $result=mysql_query($sql); //check if query successful if($result){ echo "Successful"; echo "<BR>"; echo "<a href='viewguestbook.php'>View guestbook</a>"; // link to view guestbook page } else { echo "ERROR"; } mysql_close(); ?> Code: [Select] <table width="400" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td><strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a> </strong></td> </tr> </table> <br> <?php $mysql_host = "myhost"; $mysql_database = "guest"; $mysql_user = "myusername"; $mysql_password = "mypassword"; $tbl_name="guestbook"; // Table name // Connect to server and select database. mysql_connect("$mysql_host", "$mysql_user", "$mysql_password") or die("cannot connect server "); mysql_select_db("$mysql_database") or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td>ID</td> <td>:</td> <td><? echo $rows['id']; ?></td> </tr> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><? echo $rows['name']; ?></td> </tr> <tr> <td>Email</td> <td>:</td> <td><? echo $rows['email']; ?></td> </tr> <tr> <td valign="top">Comment</td> <td valign="top">:</td> <td><? echo nl2br($rows['comment']); ?></td> </tr> <tr> <td valign="top">Date/Time </td> <td valign="top">:</td> <td><? echo $rows['datetime']; ?></td> </tr> </table></td> </tr> </table> <BR> <? } mysql_close(); //close database ?> I set up the following code to successfully individual items based on the id number. ?id=1 etc. However, I thought it would be simple to change to show another row so I changed all the terms to 'description'. However, if I enter ?description=abcde it shows nothing. But if I type in ?description=description is bizarrely shows everything. The only thing I can only put it down to is numbers. Does $_GET react differently react differently to numbers or does it require commas surrounding the string? <?php if( isset($_GET['description'])) $_GET['description']; $query = "SELECT * FROM productfeed WHERE description = $description LIMIT 0, 10"; $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>'); while($row = mysql_fetch_array($fetchdata)) { $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; echo "<div class='productdisplayshell'> <div class='productdisplayoutline'> <div class='productborder'><center> <a href='$link' target='_blank'><img src='$image'/></a> </center> </div></div> <div class='productdescriptionoutline'> <div class='productdescriptionbox'> <a href='$link' target='_blank' >$description</a> </div> <div class='productfulldescriptionbox'>$fulldescription</div> </div> <div class='productpriceoutline'> <div class='productpricebox'> <center>&#163; $price</center> </div> <div class='productbuybutton'> <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center> </div> </div> </div>"; } ?> Hello and ty all for helping I have located the problem its in login.php file but dont know where thats why am turning to experts of coding. My file is located here ftp.sofo.si username and password are same "guest" pls feel free to download and inspect Thank you again for any help cheers Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Folks,
What is wrong with the block text with the label "Description" ? All html after or below it in the file shows-up inside the block-text box when you check the page in the browser! <form name "link_submission_form" method = "post" action="" enctype = "multipart/form-data"> <div class="form-group"> <p align="left"><label>Url:</label> <select> <option value="<?php echo "$primary_domain";?>"><?php echo "$primary_domain";?></option> </select> <input type="url" placeholder="<?php echo '/directory/page.html';?>" name="primary_website_url" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['primary_website_url'])) { echo htmlentities($_POST['primary_website_url']); }?>"> <label>; Anchor Text:</label> <input type="text" placeholder="Enter Link Text" name="anchor_text" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['anchor_text'])) { echo htmlentities($_POST['anchor_text']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Page Title:</label> <input type="text" placeholder="Enter Page Title" name="page_title" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['page_title'])) { echo htmlentities($_POST['page_title']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Page Description:</label> <textarea rows="10" cols="100" placeholder="Page Description" name="page description" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['page_description'])) { echo htmlentities($_POST['page_description']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Primary Website Email (To receive Visitor Entry Alerts):</label> <input type="text" placeholder="Email to receive Visitor Entry Notice" name="primary_website_email_for_visitor_entry_notice" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['primary_website_email_for_visitor_entry_notice'])) { echo htmlentities($_POST['primary_website_email_for_visitor_entry_notice']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Repeat Primary Website Email (To receive Visitor Entry Alerts):</label> <input type="text" placeholder="Repeat Email to receive Visitor Entry Notice" name="primary_website_email_confirmation_for_visitor_entry_notice" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['primary_website_email_confirmation_for_visitor_entry_notice'])) { echo htmlentities($_POST['primary_website_email_confirmation_for_visitor_entry_notice']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Primary Website Email (To receive Visitor Exit Alerts):</label> <input type="text" placeholder="Email to receive Visitor Exit notice" name="primary_website_email_for_visitor_exit_notice" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['primary_website_email_for_visitor_exit_notice'])) { echo htmlentities($_POST['primary_website_email_for_visitor_exit_notice']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Repeat Primary Website Email (To receive Visitor Exit Alerts):</label> <input type="text" placeholder="Repeat Email to receive Visitor Exit notice" name="primary_website_email_confirmation_for_visitor_exit_notice" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['primary_website_email_confirmation_for_visitor_exit_notice'])) { echo htmlentities($_POST['primary_website_email_confirmation_for_visitor_exit_notice']); }?>"> </p> </div> <div class="form-group"> <p align="left"><label>Agree To Our Terms & Conditions ? :</label> <input type="radio" name="fb_tos_agreement_reply" value="Yes" <?php if(isset($_POST['fb_tos_agreement_reply'])) { echo 'checked'; }?> required>Yes <input type="radio" name="fb_tos_agreement_reply" value="No" <?php if(isset($_POST['fb_tos_agreement_reply'])) { echo 'checked'; }?> required>No </p> </div> <p align="left"><input type="submit" class="btn btn-default" name="submit" value="Submit"></p> <p align="left"><input type="reset" class="btn btn-default" name="reset" value="Reset"></p> </form> Notice each input field's requirement. Have I got any wrong ? Example: <input type="text" placeholder="Enter Link Text" name="anchor_text" required [A-Za-z0-9] autocorrect=off value="<?php if(isset($_POST['anchor_text'])) { echo htmlentities($_POST['anchor_text']); }?>"> Ok, here is the whole code for the downline, but the problem is that it doesn't show members below that one I mean if b follows a, and c follows b and I opened the page of A, it will only show A's info, and not bring B and C in the downline Code: [Select] <?php if($_REQUEST["i"]){ GenerateTree($_REQUEST["i"]); } else{ GenerateTree($_GET['id']); } function GenerateTree($memberid){ $l1="<img src='icon.gif' width='33' height='45' alt='No Record' longdesc='#' />";$l2="<img src='icon.gif' width='33' height='45' alt='No Record' longdesc='#' />"; $query = "SELECT * FROM users where recruiteris='".$memberid."' order by type"; //echo $query; $result = mysql_query($query); //var_dump($result); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { if($row["type"]=="Company"){$l1=getDownline($row["id"]);} if($row["type"]=="client"){$l2=getDownline($row["id"]);} } mysql_free_result($result); echo "<table border='0' class='mainTable' cellspacing='0' cellpadding='3' style='width:100%'>\n"; echo "<tr><td colspan='3' style='text-align:center;'>Login ID: ".$memberid.getInfo($memberid)."<br />"."</td></tr>"; echo "<tr><td colspan='3'>".getDownline($memberid)."</td></tr>"; echo "<tr><td style='width:33%;'>".$l1."</td><td style='width:33%;'>".$l2."</td>"; echo "</table>\n"; } function getDownline($memberid){ $query = "SELECT * FROM users where recruiteris='".$memberid."' order by type"; //echo $query; $result = mysql_query($query); //var_dump($result); $final = "<table border='0' style='width:100%;' class='internalTable' cellspacing='0' cellpadding='2'>\n"; $final .= "<tr>"; $nothing=true; $x=0; $pre; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $x++; $_SESSION['s']=0; if($row["type"]=="Company" && $x==1){$final .= "<td style='width:33%; background-color:#FFFFEC;' title='".getToolTip($row["login_id"])."'><a href='gen.php?i=".$row["login_id"]."'>".$row["login_id"]."</a><br />".$row["m_name"]."<br />Position: ".$row["form_type"]."<br />Downline - ".getCount($row["login_id"]).$_SESSION['s']."</td>";} if($row["type"]=="client" && $x==2){$final .= "<td style='width:33%; background-color:#E1F0FF;' title='".getToolTip($row["login_id"])."'><a href='gen.php?i=".$row["login_id"]."'>".$row["login_id"]."</a><br />".$row["m_name"]."<br />Position: ".$row["form_type"]."<br />Downline - ".getCount($row["login_id"]).$_SESSION['s']."</td>";} if($row["type"]=="client" && $x==1){$final .= "<td style='width:33%'><img src='icon.gif' width='33' height='45' alt='No Record' longdesc='#' /></td><td style='width:33%; background-color:#E1F0FF' title='".getToolTip($row["login_id"])."'><a href='gen.php?i=".$row["login_id"]."'>".$row["login_id"]."</a><br />".$row["m_name"]."<br />Position: ".$row["form_type"]."<br />Downline - ".getCount($row["login_id"]).$_SESSION['s']."</td>";} $pre = $row["type"]; $nothing=false; } if($nothing){$final .= "<td style='width:33%'><img src='icon.gif' width='33' height='45' alt='No Record' longdesc='#' /></td><td style='width:34%'><img src='icon.gif' width='33' height='45' alt='No Record' longdesc='#' /></td>"; } if($x==1 && $pre=="Company"){$final .= "<td style='width:33%'><img src='icon.gif' width='33' height='45' alt='No Record' longdesc='#' /></td>";} mysql_free_result($result); $final .= "</tr>"; $final .= "</table>\n"; return $final; } function getToolTip($id){ $query = "SELECT * FROM users where id ='".$id."'"; $result = mysql_query($query); $res; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $res = "fade=[off] cssheader=[toolHeader] cssbody=[toolBody] header=[Detail For ID () - ".$id."] body=[".$row["m_name"]."<br />Address:<br />".$row["address"]."]"; } mysql_free_result($result); return $res; } function getInfo($id){ $query = "SELECT * FROM users where id='".$id."'"; $result = mysql_query($query); $res; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $res = "<br />Name: ".$row["fname"]."<br />National ID: ".$row["nid"]."<br />"; } mysql_free_result($result); return $res; } function getCount($id){ $query = "SELECT * FROM users where recruiteris='".$id."'"; $result = mysql_query($query); $count = mysql_num_rows($result); $_SESSION['s'] = $_SESSION['s']+$count; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { getCount($row["id"]); } mysql_free_result($result); //echo $count."<br />"; return ""; } // Closing connection mysql_close($link); ?> I know they do, because I tested with.
die($HASH_Pass);
And it returned the same password as the password stored with the username associated in the database.
<?php /* <p class="required">All fields are required</p><br/> <form method="post" action="Scripts/UserFunctions/login.php"> <label for="username">Username:</label><input type="text" name="username" id="username" size="40px"><br/> <label for="password">Password:</label> <input type="password" name="password" id="password" size="40px"><br/> <input type="submit" name="submit" value="Login"> </form> */ if(isset($_POST['submit'])){ //set default variables $msg = ""; $error = false; //set variables from user input $Username = $_POST['username']; $Password = $_POST['password']; $HASH_Pass = hash("sha512", $Password); //include connection require_once("../DB/connect.php"); //create quarries to get data $Query = $connect->prepare("SELECT * FROM Users WHERE Username = :hhh AND Password = :jjj"); $Query->bindValue(':hhh', $Username); $Query->bindValue(':jjj', $HASH_Pass); $Query->execute() or die("Not executed"); $ROWS = $Query->fetch(PDO::FETCH_NUM); if($ROWS != 0){ $_SESSION['Logged_in']=$Username; header("Location: http://www.family-line.dx.am/Community/profile.php?user=$Username"); exit(); } else { $msg .= "Username and Password do not match. Try again"; $error = true; } if($error){ $Self = $_SERVER['PHP_SELF']; echo <<<form <div style="background: #efefef;"> <h2 style="color: red; font-weight: 850;">{$msg}</h2> <p class="required">All fields are required</p><br/> <form method="post" action="{$Self}"> <label for="username">Username:</label><input type="text" name="username" id="username" size="40px"><br/> <label for="password">Password:</label> <input type="password" name="password" id="password" size="40px"><br/> <input type="submit" name="submit" value="Login"> </form> </div> form; } } ?>Spelled Queries wrong…sorry I'm using PDO (obviously), but is there anything that would cause this error? I've made a working Login script, but I never used bindValue()... I'm new here. But I'm pretty sure it's not the SQL's issue, because it never displayed the or die(...) Not sure if this helps but the script is here... http://family-line.d....php?page=login Username: Test Password: Test Edited by Masonh928, 11 January 2015 - 06:55 PM. Ok, the sql seems to be working fine, but when I go into the while loop, it gives me an internal error 500 and doesn't load anything. It just shows me a blank white screen: Code: [Select] $sql = "SELECT alertID,alertName,alertMessage,activateSubj,activateBody,deactivateSubj,deactivateBody FROM alerts ORDER BY alertName"; $result = mysqli_query($cxn, $sql) or die(mysqli_error()); while ($row = mysqli_fetch_assoc($result)) { $alertID = $row['alertID']; $alertName = stripcslashes($row['alertName']); $alertMessage = stripcslashes($row['alertMessage'])); $activateSubj = stripcslashes($row['activateSubj'])); $activateBody = stripcslashes($row['activateBody'])); $deactivateSubj = stripcslashes($row['deactivateSubj'])); $deactivateBody = stripcslashes($row['deactivateBody'])); <div class="alert" style="border:1px solid #000;border-radius:5px;padding:12px;"> echo $alertID."<br />"; echo $alertName."<br />"; echo $alertMessage."<br />"; echo $activateSubj."<br />"; echo $activateBody."<br />"; echo $deactivateSubj."<br />"; echo $deactivateBody."<br />"; </div> } |