PHP - Php Login Button Not Working
I am totally new in PHP, can anyone help me with this problem:
Login Button is not working after clicking this button this should print a echo message. <from action="" method="POST"> <input type="text" placeholder="username"> <br> <input type="password" placeholder="Password"><br> <input type="submit" name="login" value="Login"> </from> <?php if ( isset($_POST['login'])){ echo "hissssssssssssssssssss"; } ?>
Similar TutorialsHey there guys, I have been trying to resolve this myself the past hour or so and I can't seem to figure it out. I am in the middle of programming a contacts database, with a login system. Now, the register.php file I created to create users for the database works, but the following code is from my login.php file. When I am on the page in my browser and I type in a registered username and password combination it simply just reloads the login.php file, with blank form fields, as if you had just loaded the page. I am not quite sure what is causing this. Here is the code from my login.php file: <?php //Database Information $dbhost = "removed_for_this_post"; //Host Name $dbname = "removed_for_this_post"; //Database Name $dbuser = "removed_for_this_post"; //Database Username $dbpass = "removed_for_this_post"; //Database Password //Connect To Database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $username = $_POST['username']; $password = md5($_POST['password']); $query = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = "Bad Login"; include "login.html"; } else { $_SESSION['username'] = "$username"; include "main_interface.php"; } ?> Thanks for your help in advance!! Hey guys ive put together a super simple login and i can figure out the problem since it just wont create the sessions and echo the default error If anyone has any idea why i am getting this issue that would be awesome Code: [Select] <?php session_start(); // dBase file include "../admin/config.php"; if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `nm_users` WHERE `username`='".$_POST["username"]."' AND `password`=PASSWORD('".$_POST["password"]."') LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: members.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information."); } ?> Every time I click login on my html document the php is displayed any help, would be great.
<?php I have dynamic images that have the "Like" button, it's basically like a wishlist. The way I want it to work is that when a user is not logged in, the 'Like' button will navigate them to a login popup (which I already made). My Login Script is not working! Please someone help. I am typing in the correct email and password! Mysql Table Table - Users email varchar 100 password varchar 256 form Code: [Select] action/members.php Code: [Select] <?php session_start(); include("../config.inc.php"); include("../classes/class.action.php"); if ($_POST['login'] && $_POST['*****'] == '*****') { $info = array(); $info['email'] = $_POST['email']; $info['password'] = hash("sha256", $_POST['password']); if ($Action->Login($info)) { $_SESSION['CPLoggedIn'] = $_POST['email']; header("Location: ../index.php"); } else { $Error[] = '- Please check you email and password!'; $_SESSION['CPErrors'] = $Error; header("Location: ../index.php?action=LoginForm"); } } classes/class.actions.php Code: [Select] <?php class Action { var $Erros = array(); function Login($info) { foreach ($info as $key => $val) { if ($key = "password") { $$val = mysql_real_escape_string($val); $password = hash("sha256", $val); $values[$key] = $password; } else { $values[$key] = mysql_real_escape_string($val); } } $Sql = "SELECT * FROM Users WHERE email = '{$values['email']}' AND password = '{$values['password']}'"; $Query = mysql_query($Sql); $Num = mysql_num_rows($Query); if ($Num > 0) { return true; } else { return false; } } } $Action = new Action; I'm making a login/sign up page and the following pieces are not working together properly. When I set up the login page following a guide, it had me direct input the structure and I added a user (password is encrypted). When I log in with that password/username, it passes authentication.php perfectly. When I use my signup form (signup.php is simply called by a button on an HTML), it fails saying "Incorrect Password!". I'd say it's failing because of encryption but it passes with my old login that is encrypted so I'm thoroughly lost. Authentication.php <?php session_start(); // Change this to your connection info. $DATABASE_HOST = 'localhost'; $DATABASE_USER = 'root'; $DATABASE_PASS = 'test'; $DATABASE_NAME = 'login'; // Try and connect using the info above. $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME); if ( mysqli_connect_errno() ) { // If there is an error with the connection, stop the script and display the error. die ('Failed to connect to MySQL: ' . mysqli_connect_error()); } // Now we check if the data from the login form was submitted, isset() will check if the data exists. if ( !isset($_POST['username'], $_POST['password']) ) { // Could not get the data that should have been sent. die ('Please fill both the username and password field!'); } // Prepare our SQL, preparing the SQL statement will prevent SQL injection. if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) { // Bind parameters (s = string, i = int, b = blob, etc), in our case the username is a string so we use "s" $stmt->bind_param('s', $_POST['username']); $stmt->execute(); // Store the result so we can check if the account exists in the database. $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($id, $password); $stmt->fetch(); // Account exists, now we verify the password. // Note: remember to use password_hash in your registration file to store the hashed passwords. if (password_verify ($_POST['password'], $password)) { // Verification success! User has loggedin! // Create sessions so we know the user is logged in, they basically act like cookies but remember the data on the server. session_regenerate_id(); $_SESSION['loggedin'] = TRUE; $_SESSION['name'] = $_POST['username']; $_SESSION['id'] = $id; header('Location: dashboard.php'); } else { echo 'Incorrect password!'; } } else { echo 'Incorrect username!'; } $stmt->close(); } ?>
Signup.php <?php // get database connection include_once '../config/database.php'; // instantiate user object include_once '../objects/user.php'; $database = new Database(); $db = $database->getConnection(); $user = new User($db); // set user property values $user->username = $_POST['uname']; $user->password = base64_encode($_POST['password']); $user->created = date('Y-m-d H:i:s'); // create the user if($user->signup()){ $user_arr=array( "status" => true, "message" => "Successfully Signup!", "id" => $user->id, "username" => $user->username ); } else{ $user_arr=array( "status" => false, "message" => "Username already exists!" ); } print_r(json_encode($user_arr)); ?>
login.php <?php // include database and object files include_once '../config/database.php'; include_once '../objects/user.php'; // get database connection $database = new Database(); $db = $database->getConnection(); // prepare user object $user = new User($db); // set ID property of user to be edited $user->username = isset($_GET['username']) ? $_GET['username'] : die(); $user->password = base64_encode(isset($_GET['password']) ? $_GET['password'] : die()); // read the details of user to be edited $stmt = $user->login(); if($stmt->rowCount() > 0){ // get retrieved row $row = $stmt->fetch(PDO::FETCH_ASSOC); // create array $user_arr=array( "status" => true, "message" => "Successfully Login!", "id" => $row['id'], "username" => $row['username'] ); } else{ $user_arr=array( "status" => false, "message" => "Invalid Username or Password!", ); } // make it json format // print_r(json_encode($user_arr)); if (in_array("Successfully Login!", $user_arr)) { header('Location: ../../dashboard.html'); } ?>
Hi, I made a login/register system and it was working fine, but now I seem to have broken it and I'm scratching my head as to why. I think it's something to do with the $_SESSION array, the error happens from going from the login.php page to members.php, I log in successfully, but when I get to the members page it says "you must be logged in". index.php has the form to login or a link to register.php to make an account Code: [Select] <?php session_start(); ?> <html> <head> <title>Lincs Crusade | Login page.</title> </head> <body> <form action="login.php" method="POST"> Username: <input type="text" name="username"><br /> Password: <input type="password" name="password"><br /> <input type="submit" value="Login"> </form> <a href="register.php">Click here to register!</a> </body> </html> The register.php page Code: [Select] <?php session_start(); echo "<h2>Register</h2>"; $submit = $_POST['submit']; $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); $repeatpassword = strip_tags($_POST['repeatpassword']); $email = $_POST['email']; $date = date("Y-m-d"); if ($submit) { if ($username&&$password&&$repeatpassword&&$email) { if ($password==$repeatpassword) { if (strlen($username)>65) { echo "Length of username is too long!"; } elseif (strlen($email)>100) { echo "Length of email is too long!"; } elseif (strlen($password)>65||strlen($password)<8) { echo "Password must be between 8 and 65 characters long!"; } else { include('functions.php'); echo "All fields were accepted! "; $password = md5($password); $repeatpassword = ($repeatpassword); $email = md5($email); connect(); mysql_query(" INSERT INTO users VALUES ('','$username','$password','$email','$date') ") or die("Could not insert values into <em>users</em> table!"); mysql_query(" INSERT INTO stats VALUES ('$username',10,10,0,1) ") or die("Could not insert values into <em>stats</em> table!"); $_SESSION['username'] == $username; die("You have been registered! Please return to <a href=\"index.php\">homepage</a> and login."); } } else { echo "Your passwords do not match!"; } } else { echo "Please fill in <em>all</em> fields!"; } } ?> <html> <head> <title>Lincs Crusade | Register an Account.</title> </head> <body> <form action="register.php" method="POST"> <p>Your username:</p> <p>Note: Do not use your real name.</p> <input type="text" name="username" value="<?php echo $username ?>"/>= <p>Choose a password:</p> <input type="password" name="password" /> <p>Please repeat password:</p> <input type="password" name="repeatpassword" /> <p>Your student email:</p> <p>Note: This is only used for recovering a lost or forgotten password.</p> <input type="text" name="email" /><br /> <input type="submit" value="Register" name="submit" /> <p> Note: Your password and email are md5 encrypted. This means neither I (the author) or anyone else will be able to view your information<br /> in plain text. For example, your password or email will look something like this "534b44a19bf18d20b71ecc4eb77c572f" once it has been encrypted. </p> </form> </body> </html> The login.php page that process the form data to access members.php page Code: [Select] <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { include('functions.php'); connect(); $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrow = mysql_num_rows($query); if ($numrow!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&md5($password)==$dbpassword) { echo "You're in! - <a href=\"members.php\">Proceed to the members page</a>"; $_SESSION['username'] == $username; } else { echo "Incorrect password!"; } } else { die ("That user doesn't exist,<a href=\"register.php\">please register an account</a>"); } } else { die("Please enter a username and password!"); } ?> The members.php page Code: [Select] <?php session_start(); ?> <html> <head> <title>Lincs Crusade | Members page.</title> </head> <body> <?php if ($_SESSION['username']) { echo "Welcome," .$_SESSION['username']. "!<br />"; echo "<a href=\"stats.php\">View your stats.</a>"; } else { die ("You must be logged in."); } ?> </body> </html> and this is what is in the functions.php file Code: [Select] <?php function connect() { mysql_connect("localhost","root","password") or die ("Unable to connect"); mysql_select_db("database") or die ("Unable to find database"); } ?> Thanks for your help. Hello all, I'm new to any kind of coding, but I recently graduated college with an English degree and decided to try to become a technical writer, but quickly realized I would need to learn some basic coding to publish stuff as many companies are moving away from paper. Anyway, that's the background to why I'm about to ask a really simple question: I wrote a login script, and it rejects people correctly who don't have the correct credentials, and it accepts the people that do, but while the failed attempts send the appropriate alert (the alert also pops up when u first open the page, which if you all can figure out why and stop it, that would be awesome, but its not the main problem), for those who do log in it does not send them to the link that I'm trying to send them to upon log in. Instead, they stay on the same page, but the login text boxes are gone. Any help would be appreciated, thanks. Here is the code: <html> <body style="background-color:rgb(240,230,200);font-family:Times;font-size:110%;"> <p style="text-align:center;font-family:Arial;font-size:250%"> ///text removed for privacy///</p> <p style="text-align:center;font-family:Arial;font-size:200%"> ////text removed for privacy </p> <CENTER><img src="////removed for privacy/////" width="700" height="500"/></Center> <p style="text-align:center;"> To access the site, please use enter your User ID and Password. </p> <center> <?php error_reporting (E_ALL ^ E_NOTICE); ?> <?php session_start(); include("passwords.php"); if ($_POST["ac"]=="log") { if ($USERS[$_POST["username"]]==$_POST["password"]) { $_SESSION["logged"]=$_POST["username"]; } else { echo 'Please enter a vaild Username and Password'; }; }; if (array_key_exists($_SESSION["logged"],$USERS)) header("index.html"); else { echo "<script>alert('Please enter valid Username and Password')</script>"; echo '<form action="login.php" method="post"><input type="hidden" name="ac" value="log"> '; echo 'Username: <input type="text" name="username" /><br />'; echo 'Password: <input type="password" name="password" /><br />'; echo '<input type="submit" value="Login" />'; echo '</form>'; } ?> </center> </body> </html> My code does not have any errors. However, when I test it, all it says is "you have entered an incorrect username and password. But I can't even see the username and password text boxes to enter a username or password. Hello, for some reason I am unable to get the following code to work: Code: [Select] <?php echo "<h1>Login</h1>"; if ($_SESSION['uid']) { echo " You are already logged in, if you wish to log out, please <a href=\"./logout.php\">click here</a>!\n"; } else { if (!$_POST['submit']) { echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"./login.php\">\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n"; echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Login\"></td></tr>\n"; echo "</form></table>\n"; }else { $user = addslashes(strip_tags(($_POST['username']))); $pass = addslashes(strip_tags($_POST['password'])); if($user && $pass){ $sql = "SELECT id FROM `users` WHERE `username`='".$user."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0){ $sql2 = "SELECT id FROM `users` WHERE `username`='".$user."' AND `password`='".md5($pass)."'"; $res2 = mysql_query($sql2) or die(mysql_error()); if(mysql_num_rows($res2) > 0){ $query = mysql_query("SELECT locked FROM `users` WHERE `username`='".$user."'"); $row2 = mysql_fetch_assoc($query); $locked = $row2['locked']; $query = mysql_query("SELECT active FROM `users` WHERE `username`='".$user."'"); $row3 = mysql_fetch_assoc($query); $active = $row3['active']; $query = mysql_query("SELECT email FROM `users` WHERE `username`='".$user."'"); $row3 = mysql_fetch_assoc($query); $email = $row3['email']; if ($active ==1){ if ($locked == 0){ $date = date("j")."<sup>".date("S")."</sup> ".date("F, Y"); mysql_query("UPDATE users SET last_login='$date' WHERE username='$user'"); $row = mysql_fetch_assoc($res2); $_SESSION['uid'] = $row['id']; $previous = $_COOKIE['prev_url']; echo " You have successfully logged in as " . $user . "<br><br><a href='" . $previous . "'>Click here</a> to go to the previous page.\n"; }else { echo "Your acount has been locked out due to a violation of the rules, if you think there has been a mistake please <a href='contact.php'>contact us</a>."; } } else { echo "You need to activate your account! Please check your email ($email)"; } }else { echo " Username and password combination are incorrect!\n"; } }else { echo " The username you supplied does not exist!\n"; } }else { echo " You must supply both the username and password field!\n"; } } } ?> It says that I have logged in successfully but the session is not created. You can find the script here and log in with the username "test" and the password "testing". I'm not sure what more information I should add. Thanks, Cameron I have a form on my website which actions login.php. The login.php code is below: <?php include('includes/classes.php.inc'); session_start(); $link = new BaseClass(); $data = $link->query("SELECT * FROM logins"); $pass_accepted = false; if($_REQUEST['username'] && $_REQUEST['password']){ $username = $_REQUEST['username']; $password = $_REQUEST['password']; while($row = mysql_fetch_array($data)){ if(($row['username']==$useranme)&&($row['password']==$password){ echo 'Password correct!'; $_SESSION['loggedin']=true; $pass_accepted = true; } } } else { echo 'You did not enter a username or password!'; } if(!$pass_accepted){ echo 'Your password is incorrect'; } echo '<br>Please <a href="index.php">click here</a> to return to page'; ?> I have checked that my references are all correct however even when I enter the correct password it returns saying the password is incorrect. Any idea on why this could be? I am happy to answer any follow up questions. Regards I am trying to create a remote login to one website using mine. The users will need to enter their username and password on my site, and if they are registered to my website, their login credentials will be sent to another website and a page will be retrieved.
I am stuck at sending the users' data to the original site. The original site's viewsource is this..
<form method=post> <input type="hidden" name="action" value="logon"> <table border=0> <tr> <td>Username:</td> <td><input name="username" type="text" size=30></td> </tr> <tr> <td>Password:</td> <td><input name="password" type="password" size=30></td> </tr> <td></td> <td align="left"><input type=submit value="Sign In"></td> </tr> <tr> <td align="center" colspan=2><font size=-1>Don't have an Account ?</font> <a href="?action=newuser"><font size=-1 color="#0000EE">Sign UP Now !</font></a></td> </tr> </table>I have tried this code, but not works. <?php $username="username"; $password="password"; $url="http://www.example.com/index.php"; $postdata = "username=".$username."&password=".$password; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); header('Location: track.html'); //echo $result; curl_close($ch); ?>Any help would be appreciated, Thanks in advance. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348317.0 heres the line for my button Code: [Select] echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location = post_reply.php?cid=".$cid."&tid=".$tid."\" /><hr /> "; for some reason when i click on it in the site it does not do anything, but when i type the link in maunaly that the button should link to the page works. heres the code for the page that the button is on Code: [Select] <?php require("top.php"); ?> <div id='content'> <div id='homepageright'> <?php require("scripts/connect.php"); if($username){ $cid = intval($_GET['cid']); $tid = intval($_GET['tid']); $sql = "SELECT * FROM topics WHERE category_id = $cid AND id = $tid"; $res = mysql_query($sql) or die(mysql_error()); /*$cid = $_GET['cid']; $tid = $_GET['tid']; $sql = "SELECT * FROM topics WHERE category_id='".$cid."' AND id='".$tid."'"; $res = mysql_query($sql) or die(mysql_error());*/ if(mysql_num_rows($res) == 1){ echo "<table width='100%'>"; if($username){ echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location = post_reply.php?cid=".$cid."&tid=".$tid."\" /><hr /> "; } While ($row = mysql_fetch_assoc($res)) { $sql2 = "SELECT * FROM post WHERE category_id='".$cid."' AND topic_id= '".$tid."'"; $res2 = mysql_query($sql2) or die(mysql_error()); while ($row2 = mysql_fetch_assoc($res2)) { echo "<tr><td valign='top' style='border: 1px solid #000000;'><div style='min-height: 125px; '>".$row['topic_title']."<br /> by ".$row2['post_creator']." - ".$row2['post_date']. "<hr /> ".$row2['post_content']."</div></td><td width='200' valign='top' align='center' style='border: 1px solid #000000;'>User Info Here</td></tr><tr><td colspan='2'><hr /></td></tr>"; } echo "</table>"; } } else{ echo "This Topic Does Not Exist."; echo "$sql"; } } else{ echo "You Must Be Logged In To Continue."; } ?> </div> <div id='homepageleft'> <?php ?> </div> </html> </body> Why the button "Enviar Emails" is not working? --> http://www.ibnshare.com/email/ (login: 123abc password: 123abc) Code: [Select] echo '<form action = "send.php" method = "post">'; echo '<strong>Assunto do Email</strong><br />'; echo $emailSubject; echo '<br />'; echo '<strong>Corpo do Email</strong><br />'; echo $emailBody; echo '<br /><br />'; echo '<input name = "send" type = "button" value = "Enviar Emails" />'; echo '</form>'; Hi - I designed a regular website using html. One page I used was on the previous site, and it had links to a database. Its for an online wedding registry. Problem is, on the page that pulls up with the couples list of wish list items, there is a "Print the Bliss List" link that is not working, right below the list. It is just seen as text on the page, not a button element. Can you look at the code and see why this isn't working or what I can do to fix it? I use Dreamweaver CS5 and am familiar with working in html, and css code, but not php. Here is the link to the page in question:
http://getinteriormo...s2.php?id=03313
thanks so much!
I have developed a code for a login and seems to work well (No syntax error according to https://phpcodechecker.com/ but when I enter a username and a password in the login form, I get an error HTTP 500. I think that everything is ok in the code but obviously there is something that I am not thinking about. The code (excluding db connection): $id="''"; $username = $_POST['username']; $password = md5($_POST['password']); $func = "SELECT contrasena FROM users WHERE username='$username'"; $realpassask = $conn->query($func); $realpassaskres = $realpassask->fetch_assoc(); $realpass= $realpassaskres[contrasena]; $func2 = "SELECT bloqueado FROM users WHERE username='$username'"; $blockedask = $conn->query($func2); $blockedres = $blockedask->fetch_assoc(); $bloqueado = $blockedres[bloqueado];
//Login if(!empty($username)) { // Check the email with database I trying to make it so i can in put the data from a database into a theme i got from theme forest but im having few problems. the theme and page http://warp.nazwa.pl/dc/innovation/portfolio.html The NEXT button on the portfolio see how it slides across and works nicely here but on my page http://www.jigsawsoulmedia.com/root/Files/jigsawsoulmedia.com/_public/template.php its stopped working since I've place my php code in there and i can't see why not, everything look right to be from the html and php. Could one you lovely people see what you can spot wrong. page code with php below <!-- PAGE CONTENT HERE, PORTFOLIO LIST AND RIGHT SIDE BAR --> <div id="portoflioHeaderContainer"> <!-- PAGE TITLE AND NAVIGATION TREE --> <h1 class="commonPageTitle">Portfolio</h1> <div id="navigationTreeContainer"> <a href="index.html" class="prev">Home</a> \ <a class="current">Portfolio</a> </div> <!-- navigationTreeContainer --> <!-- SHORT TEXT THAT DESCRIBE PAGE CONTENT --> <p class="commonIntroductionText"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae. Nemo enim ipsam voluptatem quia <span class="spanBold">voluptas sit aspernatur</span> aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet consectetur, adipisci velit. </p> <!-- PORTFOLIO STATISTICS, CURRENT/ALL PAGE AND CURRENT/ALL PROJECT NUMBER --> <div class="portfolioStatisticsContainer"> <div class="pageStatsWrapper"> <span id="pageNumber"></span><span id="pageCount"></span> </div> <div class="imageStatsWrapper"> <span id="hoveredImageIndex">Project: 1/</span><span id="numberOfImages">0</span> </div> </div> <!-- portfolioStatisticsContainer --> </div> <!-- portoflioHeaderContainer --> <div id="portfolioContainer"> <div class="portfolioPage"> <?php $result = "SELECT * FROM portfolio"; $result = mysql_query ($result) or die (mysql_error()); $i=0; while($row = mysql_fetch_assoc($result)) { if($i==2) $divclass = 'portfolioProjectWrapper borderWhite'; else $divclass = 'portfolioProjectWrapper borderGray'; echo ' <div class="'.$divclass.'"> <a href="portfolioPage.html" class="image asyncImgLoad" title="img/'.$row['image290x290'].'"></a> <p class="imageDesc">'.$row['image290x290_phot'].'</p> <h3 class="title">'.$row['title'].'</h3> <p class="subtitle">'.$row['subtitle'].'</p> <p class="desc"> '.substr($row['description'], 0, 1200).' <a href="portfolioPage.html" class="commonLink">Read more</a> </p> </div> '; if($i==2) $i=0; else $i++; } ?> </div><!-- portfolioPage --> </div> <!-- portfolioContainer --> <!-- PORTFOLIO CONTROL PANEL --> <div id="portfolioControlPanel"> <div id="portfolioPrevPageBtn">Prev page</div> <div id="portfolioNextPageBtn">Next page</div> </div> <!-- portfolioControlPanel --> <div class="clearBoth"></div> Thanks for taking a look! I'm trying to use checkbox to choose multiple data and submit(button 'Send SMS') them and direct them to another page, which will send text SMS to the numbers chosen. But when I try to click on one checkbox, it automatically directs me to the next page, without having to click on the 'Send SMS' button. I tried to see which part is the problem, but I can't determine which one is wrong. Please help! Thank you.
<script type="text/javascript"> function checkedAll (frm1) {var aa= document.getElementById('frm1'); if (checked == false) { checked = true } else { checked = false }for (var i =0; i < aa.elements.length; i++){ aa.elements[i].checked = checked;} } </script> <TABLE width="1106" border="1" align="center" cellpadding="5" cellspacing="2" > <tr> <td colspan="9"> <form id ="frm1" action="sms_latecomers.php"> <input type='checkbox' name='checkall' onclick='checkedAll(frm1);' value=""> <input type="submit" name="Submit" id="button" value="SMS Reminder" style="background:#FFCC33"/> </td> </tr> <TR bgcolor="#996699"> <?php $count=0; ?> <TH width="32"></TH> <TH width="37"> <span class="style1"> <div align="center">No. </div></span></TH> <th width="101"><span class="style1">SUPERVISOR ID</span></th> <th width="101"><span class="style1">EMPLOYEE ID</span></th> <th width="153"><span class="style1">EMPLOYEE NAME</span></th> <th width="124"><span class="style1">DATE</span></th> <th width="153"><span class="style1">LATE CHECK IN</span></th> </TR> <?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <TR> <TD><input type="checkbox" name="chk1" value="<?php echo $row['supervisor_telno']; ?>" onClick="window.open('sms_latecomers.php?employee_id=<?php echo $row['employee_id']; ?>&supervisor_telno=<?php echo $row['supervisor_telno']; ?>');"></TD> <TD height="66">[bad html removed]<input type="checkbox" name="chk1" >--> <?php $count=$count+1; print($count);?></TD> <TD><div align="center"><?php echo $row['supervisor_id']; ?></div></TD> <TD><div align="center"><?php echo $row['employee_id']; ?></div></TD> <TD><div align="center"><?php echo $row['employee_name']; ?></div></TD> <TD><div align="center"><?php echo $row['DATE']; ?></div></TD> <TD><div align="center"><?php echo $row['TIME']; ?></div></TD> </TR> <?php } ?>[bad html removed]</form>--> </TABLE> Hey guys! I've looked through this code over and over today, and I still haven;t found where my error is. Here is my entire code: Code: [Select] <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Quest Agency</font><br><br>"; $startjob = $_POST['submit']; $jobq = "SELECT * FROM jobs WHERE username='$showusername'"; $job = mysql_query($jobq); $jobnr = mysql_num_rows($job); if($jobnr == "0") { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="submit" value="Start Job"></form> <?php } if(isset($startjob)) { $initemidq = "SELECT * FROM items ORDER BY RAND() LIMIT 1"; $initemid = mysql_query($initemidq); while($ir = mysql_fetch_array($initemid)) { $ids = $ir['itemid']; } mysql_query("INSERT INTO jobs (username, item, time, completed) VALUES ('$showusername', '$ids', 'None', 'No')"); $wegq = "SELECT * FROM items WHERE itemid='$ids'"; $weg = mysql_query($wegq); while($wg = mysql_fetch_array($weg)) { $im = $wg['image']; $nm = $wg['name']; $id = $wg['itemid']; } $_SESSION['theid'] = $id; $yeshere = $_SESSION['theid']; echo "<font color=green>Success! You have started this Job!</font><br><br>Please bring me this item: <b>$nm</b><br><br><img src=/images/items/$im><br><br><br>"; } if($jobnr == "1") { $yeshere = $_SESSION['theid']; $finish = $_POST['finish']; $quit = $_POST['quit']; $okgq = "SELECT * FROM items WHERE itemid='$yeshere'"; $ok = mysql_query($okgq); while($ya = mysql_fetch_array($ok)) { $okname = $ya['name']; $okid = $ya['itemid']; $okimage = $ya['image']; } $yeshere = $_SESSION['theid']; echo "Where is my <b>$okname</b>?<br><br><img src=/images/items/$okimage><br><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="finish" value="I have the Item"><br><br> <input type="submit" name="quit" value="Quit"></form> <?php } } if(isset($finish)) { $yeshere = $_SESSION['theid']; $cinq = "SELECT * FROM uitems WHERE theitemid='$_SESSION[theid]'"; $cin = mysql_query($cinq); $connr = mysql_num_rows($cin); if($connr != "0") { mysql_query("DELETE FROM uitems WHERE username='$showusername' AND theitemid='$yeshere' LIMIT 1"); mysql_query("UPDATE users SET jobs=jobs+1 WHERE username='$showusername'"); mysql_query("UPDATE users SET credits=credits+320 WHERE username='$showusername'"); mysql_query("DELETE FROM jobs WHERE username='$showusername'"); echo "<font color=green>Success! You have completed this job! You have been given <b>320</b> credits as an award. Thank You!</font>"; } else { echo "<font color=red>Error! You do not have my item!</font>"; } if(isset($quit)) { mysql_query("DELETE FROM jobs WHERE username='$showusername'"); echo "<font color=green>Success! You have quit this quest.</font>"; } $yeshere = $_SESSION['theid']; } ?> The variable for the button is: $quit = $_post and I want the quit button to work. Does anybody know why it will not work? Thank you in advance! |