Search the Community
Showing results for tags 'issue'.
-
Hello guys! I have literally started learning how to code. And I have come to the point when I got to deal with elseif syntax which is not working properly and messes up everything I have done so far. Here's the script $password = "tulip"; if ($password == "tulip") { echo '<b>Hello!</b><br> Welcome to the website Blaise!'; } else { echo '<b> The password or login is incorrect <br> Please try again </b>'; } elseif ( $password == "daisy") { echo '<b> Welcome Kate! </b>; } When I type in "daisy" nothing goes on and everything just gets stuck. Any help or explanation? Thanks
-
Im having a problem with login system. its telling me my username and password are wrong when i know they are not. here is my login.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta charset="UTF-8"> <title>Server 2 Server | Log in</title> <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> <!-- Bootstrap 3.3.4 --> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <!-- Font Awesome Icons --> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" /> <!-- Theme style --> <link href="dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" /> <!-- iCheck --> <link href="plugins/iCheck/square/blue.css" rel="stylesheet" type="text/css" /> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body class="login-page"> <div class="login-box"> <div class="login-logo"> <a href="../../index2.html"><b>Server</b>2SERVER</a> </div><!-- /.login-logo --> <div class="login-box-body"> <p class="login-box-msg">Sign in to view the control panel</p> <?php if(!empty($_GET['msg'])) { $msg = $_GET['msg']; //GET the message if($msg!=''): echo '<p>'.$msg.'</p>'; endif; } ?> <form action="check_login.php" method="post"> <div class="form-group has-feedback"> <input type="text" class="form-control" placeholder="Email" name="username" id="username"/> <span class="glyphicon glyphicon-envelope form-control-feedback"></span> </div> <div class="form-group has-feedback"> <input type="password" class="form-control" placeholder="Password" name="password" id="password"/> <span class="glyphicon glyphicon-lock form-control-feedback"></span> </div> <div class="row"> <div class="col-xs-8"> </div><!-- /.col --> <div class="col-xs-4"> <button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button> </div><!-- /.col --> </div> </form> <a href="#">I forgot my password</a><br> </div><!-- /.login-box-body --> </div><!-- /.login-box --> <!-- jQuery 2.1.4 --> <script src="../../plugins/jQuery/jQuery-2.1.4.min.js"></script> <!-- Bootstrap 3.3.2 JS --> <script src="../../bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <!-- iCheck --> <script src="../../plugins/iCheck/icheck.min.js" type="text/javascript"></script> <script> $(function () { $('input').iCheck({ checkboxClass: 'icheckbox_square-blue', radioClass: 'iradio_square-blue', increaseArea: '20%' // optional }); }); </script> </body> </html> check_login.php <?php define(DOC_ROOT,dirname(__FILE__)); // To properly get the config.php file $username = $_POST['username']; //Set UserName $password = $_POST['password']; //Set Password $msg =''; if(isset($username, $password)) { ob_start(); include(DOC_ROOT.'/config.php'); //Initiate the MySQL connection // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($username); $mypassword = stripslashes($password); $myusername = mysqli_real_escape_string($dbC, $myusername); $mypassword = mysqli_real_escape_string($dbC, $mypassword); $sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass=SHA('$mypassword')"; $result=mysqli_query($dbC, $sql); // Mysql_num_row is counting table row $count=mysqli_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "dashboard.php" session_register("admin"); session_register("password"); $_SESSION['name']= $myusername; header("location:dashboard.php"); } else { $msg = "Wrong Username or Password. Please retry"; header("location:login.php?msg=$msg"); } ob_end_flush(); } else { header("location:login.php?msg=Please enter a username and password"); } ?> it just keeys telling my my password and user and incorrect please help
-
Hi , i read many articles and tried many things before asking but i came to a dead end. My problem is very simple (or at least i believe so). In the main directory \httpdocs there is this file we call "header.php" and another file we call "article.php". So the code of the article is very simple: <?php include("header.php"); echo "bla bla bla\n"; ?> So far so good. Let's say that we create a new folder \httpdocs\new_folder and inside there we create a new file that we call "new_file.php". So we would simple like to call the header.php from the parent folder BUT IT TURNS TO BE IMPOSSIBLE ! I have tried: include('../header.php'); (in an article of this website says that this work - well IT DOESN'T ! i have tried many other things but i cannot load the header.php from the previous directory ! I wanna tip the person who will find the solution so you better leave a paypal along with the answer !
-
Here is the code for both the connection file and the main body of script. I assure you the passwords and actual names do match as I have done other tests before hand. register.php <?php $title = "Register"; include 'includes/header.php'; if($_SERVER['REQUEST_METHOD'] == 'POST') { require 'includes/connection.php'; //create FALSE figures $username = $password = FALSE; //trim all data $trimmed = array_map('trim', $_POST); $errors = array(); //check username if(preg_match ('/[A-Za-z0-9]{2,20}/', $trimmed['username'])) { $username = mysqli_real_escape_string($dbc, $trimmed['username']); } else { $errors[] = 'Enter a username'; } //check password if(preg_match ('/[A-Za-z0-9]{4,20}/', $trimmed['password'])) { $username = mysqli_real_escape_string($dbc, $trimmed['password']); } else { $errors[] = 'Enter a password'; } //variables not == FALSE if($username && $password) { $q = "SELECT user_id FROM users WHERE username='$username'"; $r = mysqli_query ($dbc, $q) OR trigger_error("Query: $q\n<br />MYSQL Error: ". mysql_error($dbc)); if(mysqli_num_rows($r) == 0) { $q = "INSERT INTO users (username, password, registration_date) VALUES ('$username', SHA1('$password'), NOW() )"; $r = mysqli_query ($dbc, $q) OR trigger_error("Query: $q\n<br />MYSQL Error: ". mysql_error($dbc)); } if(mysqli_affected_rows($dbc) == 1) { echo "success"; //header('Location: database.php'); } } else { foreach ($errors as $msg) { echo " - $msg<br />\n"; } } } ?> <form action="register.php" method="POST"> <input type="text" name="username" value="<?php if(isset($trimmed['username'])) echo $trimmed['username']; ?>" placeholder="Username"/> <input type="password" name="password" value="<?php if(isset($trimmed['username'])) echo $trimmed['password']; ?>" placeholder="Password"/> <input type="submit" class="button1" name="Sign Up" /> </form> connection.php <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $db = 'ze'; $dbc = mysqli_connect($dbhost, $dbuser, $dbpass) OR die ('Could not connect. MYSQL:' .mysql_error() ); mysql_select_db($db); Whenever I run this it does not seem to want to work, and also outputs no errors. I probably cant see something and need a second opinion.
-
Okay so I have a completely fully functional member system. Login works, register works, In this system I dont let people make two accounts with the same name, however if they have caps in different spots, it works. Any ideas how to prevent this? Any help is much appreciated! Thanks!
-
Hey guys, i am working on my site , and i have a global conditional that is pretty simple in what i want it to do , i have 4 variables that are not always set, i am writing an if elseif statement to see if whichever variable is used to then continue to its specified query/ if ($current_file == 'profile.php') { $mid = $_GET['male_id']; $fid = $_GET['female_id']; $serid = $_GET['series_id']; $id = $_GET['id']; if(isset($mid) === true){ $query = "SELECT * FROM `content` WHERE `id` = $mid"; }elseif (isset($sid) === true) { $query = "SELECT * FROM `content` WHERE `id` = $sid"; }elseif(isset($serid) === true){ $query = "SELECT * FROM `content` WHERE `id` = $serid"; }elseif(isset($id) === true){ $query = "SELECT * FROM `content` WHERE `id` = $id"; } $info = mysql_query($query); while($row = mysql_fetch_assoc($info)){ extract($row); } } now the conditional works fine , in terms of the query working and grabbing the desired data and parlaying that data onto the site. My issue is simply , i want to leave error reporting on for my users, so that if there are errors or problems i dont know of , server side , they can report this to me. When i do this, i get : any explanation as to why this is happening ? edit: i understand as to "why" , the variable that is the $_GET is now set to $sid , and the 3 other variables are not defined with since they are not in the URL. should i set the variables deeper into the conditional ? are they too global to where the entire if statement which is looking for current file and need to be set in their own if statements ? also , any suggestions on how to alter my code to provide the same results without the notice being portrayed ? much appreciated guys
-
I have a pretty beginner's question, but cant seem to get this right with what i try. I had the same problem with using LIKE and OR with multiple fields and queries. essentially i just want to ORDER BY using multiple fields i have in the DB. my query is something like this $query = "SELECT * FROM content WHERE rating > 7 ORDER BY `votes` DESC, `release_date` DESC "; now i understand with LIKE and OR you must separate arguments with (), but with ORDER BY i am not using any AND / OR so i though a comma should be sufficient. Yet, i can never seem to get this work properly. any suggestions to get both fields to ORDER BY ? thanks guys
-
Hey there guys ! so i have finally finished my register log-in page , and with that i have created a couple functions pages , as i am sure you can assume all the functions for logic will be called from these pages. now i have one called users , i.e for login , registration , check if active, etc.. and i have one for more general functions page called general , i.e for redirects, and input sanitation. anyway my register login page works flawless ( well i guess more 90 % done 90 % left to go ). and now when im on the index page or my main page essentially i now see a fatal error: now i see that it is telling me exactly where the error is , yet i dont understand as to why i am seeing this . im not quite sure as to how the function is being declared already , when the function is only being called once or twice on the register page. just to show you guys what im talking about my code: general.php ( FUNCTIONS ARE STORED) function email($to, $subject, $body){mail($to, $subject, $body, 'From: support@j.m.com'); } function email_to_activate($to, $subject, $body){ mail($to, $subject, $body, 'From: activate@j.m.com'); } function email_user_for_recovery($to, $subject, $body){ mail($to, $subject, $body, 'From: recovery@j.m.com'); } function logged_in_redirect(){ if (logged_in() === true ) header("Location: index.php"); } function protect_page() { // redirects if user is not logged in .. user gets no access page if (logged_in() === false ) { header('Location: no_permission.php'); exit(); } } function admin_access() { global $user_data; if (has_access($user_data['user_id'], 1) === false) { header('Location: index.php'); exit(); } } function page_redirect() { // if user not logged in redirect goes to index page if (logged_in() === false ) { header('Location: index.php'); exit(); } } function redirect(){ // redirects regardless of logged in or not header('Location: index.php'); exit(); } function array_sanitize(&$item){ $items = strip_tags(htmlentities(mysql_real_escape_string($item))); } function sanitize($data) { return strip_tags(htmlentities(mysql_real_escape_string($data))); } function output_errors($errors){ $output = array(); foreach($errors as $error){ $output[] = $error ; } return '<ul>' . implode($output) . '</ul>'; } and index.php // CORE FUNCTIONS - DATABASE CONNECT - SESSIONS & COOKIES include('include/init.php'); // HEADER INFO - META TAGS - LINKS - SCRIPTS include('include/header.php'); // LOG USER IN if (logged_in() === true){ include ('include/widgets/loggedin.php'); } else { include('include/widgets/login.php'); } // WEBSITE LOGO include('include/logo_head.php'); // NAVIGATION BAR include('include/navbar.php'); // MAIN PAGE include('include/topbanner.php'); include('include/topbanner2.php'); <----- Error shows up here and cuts off the rest of the page. include('include/mainbody.php'); // FOOTER include('include/footer.php'); as i mention in the code above, the page spits about half the output then cuts off and displays that error message. This confuses me a bit more actually. any suggestions as to why this is happening ? EDIT : to add init.php ( CORE FILE ) if(!isset($_SESSION)) { session_start(); } error_reporting(E_ALL| E_STRICT); ini_set('display_errors', 1); require ('core/database/dbconnect.php'); require ('core/functions/general.php'); require ('core/functions/users.php'); require 'core/queries/dbqueries.php'; $current_file = explode('/', $_SERVER['SCRIPT_NAME']); $current_file = end($current_file); if (logged_in() === true) { $session_user_id = $_SESSION['user_id']; $user_data = user_data($session_user_id, 'user_id', 'username', 'password', 'email', 'gender', 'country', 'month' ,'date' , 'year', 'pass_recover', 'type'); if (user_active($user_data['username']) === false){ session_destroy(); header('Location: index.php'); exit(); } if($current_file !== 'change_password.php' && $current_file !== 'logout.php' && $user_data['pass_recover'] == 1 ){ header('Location: change_password.php?force'); exit(); } } $errors = array();
- 2 replies
-
- fatal error
- cannot re-declare
-
(and 2 more)
Tagged with:
-
Hello my beautiful freaks, i have an issue trying to create my forgot username code. i am trying to send my end user an email with their loggin info ( more specifically the username ) <? function recover($mode, $email) { $mode = sanitize($mode); $email = sanitize($email); $user_data = user_data(user_id_from_email($email),'username'); if ( $mode == 'username') { email_user_for_recovery($email, 'Your username info', " Hello, This email has been sent from http://j.justin7410.com/recover.php You have received this email because this email address" .$user_data['email'] . ", was used during the registration process of our website. There has been a request for your forgotten username, If you did not request this information plese disregard this email. You do not need to unsubscribe or take any further action. Your sign-in username is: " .$user_data['username'] . // <--- THIS VARIABLE IS NOT BEING INDEXED CORRECTLY "Thank you for using j.justin7410.com, we hope to make your experience as easy and seamless as can be. Cheers, - team j.motionempire.com "); in general the $user_data variable is not returning the values i need. i was wondering if you guys had any good way of debugging this issue ? the variables are passing fine in other instances, but when passed through it wont echo the things i need the email received is just sending everything but the data needed/ thanks guys
-
Hey freaks, i have been working on a log in / register system for a couple days now, and i am in the process of finalizing my end users activation of a newly registered account. I was having no real issues until now, to where i am utterly confused as to why i am having such a core problem. So for the first part i had a user register, and wanted to make sure the user is not already entering an email that already exists in my Database. if (email_exists($_POST['register_email']) === true) { $errors[] = 'The email you provided is already in use. If you are having trouble remembering your user info click <a href="#">here</a>'; } the error goes to an errors array i have setup with all the errors that would display to the end user if any occur. the email_exists() is the following : function email_exists($email) { $username = sanitize($email); $query = (" SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email' "); $results = mysql_query($query); if(mysql_error()) { echo 'MySQL Error: '. mysql_error() .'<br>'; echo 'Query: '.$query; } else if(!mysql_num_rows($results)) { //### row has not been returned } else { //### row has been returned } return (mysql_result($results, 0) == 1) ? true : false; } Now everything in the function calls correctly, and as you see in the error check, row will be returned. Yet, as you see in my IF statement in the error check above, nothing is being returned with the variable i am inputting ( yet the other IF statement all seem to work with the same variable $_POST) now this i figured was the problem to my MAIN and number one issue. Getting my user activation working. if(isset($_GET['success']) === true && empty($_GET['success']) === true){ ?> <h2> Thank you, your account has been activated</h2> <h3> You can now log in and access the site and join the disscussions in out forum !</h3> <? } else if (isset($_GET['email'], $_GET['email_code']) === true){ $email = trim($_GET['email']); $email_code = trim($_GET['email_code']); if (email_exists($email) === false ){ $errors[] = ' We have a problem, we couldn\'t find that email address !'; // THIS IS THE ERROR GIVEN TO USER } else if (activate($email, $email_code) === false) { $errors[] = ' We had a problem activating your account '; } if(empty($errors) === false){ ?> <h2>Oops...</h2> <? echo output_errors($errors); } else { header('Location: activate.php?success'); exit(); } } else { header('Location: index.php'); exit(); } Now above i have highlighted what conditional is passed, when a end user click on the return link to activate their account. as i mentioned above , i know its the email_exists function, since not only does that conditional fail . in database i can create multiple users with the same email. Please guys any help would be greatly appreciated. I am a PHP / Programming noob , but i am trying my best to debug and catch my issues. i just cant figure this one out on my own .
-
Hi, I'm trying to make it so that my Wrapper fixes to the screen resolution depending on your screen, so I'm basically debugging on both my laptop and my 32"" monitor. Would they be any possible way to make it so: "height: 100%" "width: 100%" If so how would I do this method? I've got this far atm: (The wrapper is help inside the main Container which just has "width: 100%; min-width: 100%; padding: 0; margin: 0; " Excuse my sloppy coding. .index_wrapper { width: 100%; height: 1600px; min-width: 500px; max-width: 100%; min-height: 500px; max-height: 1600px; margin-top: 50px; margin-bottom: 25px; margin-right: auto; margin-left: auto; } .index_content { background-color: #1e1f1f; background-image:url('images/structure/background-2.jpg'); background-repeat: no-repeat; height: 100%; min-height: 100%; width: 100%; min-width: 1452px; border: 1px solid #505050; border-left:none; border-right:none; border-top: none; vertical-align: baseline; }
-
Hey guys, i was trying to add google recaptcha to my login register system, for a spam defense and just to give it a more professional feel. i already have my own conditional in my own system to make sure an email is not already used or to make sure a password is a certain length, etc.... i now want to add the existing code from google and add an additional conditional to make it flow as one. my issue so i followed the directions from goodle developers and when implementing the code by itself on a test page, i encounter no problems. i get the proper pass and fail, depending on what security code is entered. when i move that same logic into my already created system i then get a consistent failure with no pass. i am utterly confused as to why this is happening, if you guys can give me any suggestions that would be great. my code TEST PAGE .. WORKS FINE <?php include('include/init.php'); include('include/header.php'); require_once 'recaptchalib.php'; $privatekey = "6Lf5AeASAAAAAO5DJ1GcIAiwd8kkNbVBgrDrandom"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { echo 'FAILURE'; } else { echo 'SUCCESS'; // Your code here to handle a successful verification } ?> <tr> <form method='post' action='test.php' id='test'> <td class="register_td_left2"><span class="">Security Code:</span></td> <td valign="middle" style="padding-left:2px"> <?php require_once 'recaptchalib.php'; $publickey = "6Lf5AeASAAAAAPue6LLdUDttmPDc-NbRHcnrandom"; // you got this from the signup page echo recaptcha_get_html($publickey); ?></td> <input type='submit' value='Submit'></input> </form> </tr> Register page i try to implement the same logic require_once 'recaptchalib.php'; $privatekey = "6Lf5AeASAAAAAO5DJ1GcIAiwd8kkNbVBgrandom"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (empty($_POST) === false) { $required_fields = array('register_email','register_username','password','confirm_pass','gender','month','date','year','country'); foreach($_POST as $key => $value){ if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = '* All fields are required!'; break 1; } } if (empty($errors) === true) { if (user_exists($_POST['register_username']) === true) { $errors[] = 'Sorry, the username \'' . $_POST['register_username'] . '\' has already been taken. Please choose another username.'; } if (preg_match("/\\s/", $_POST['register_username']) == true) { $errors[] = 'Sorry your username must not contain any spaces!'; } if (strlen($_POST['password']) < 6 ){ $errors[] = 'Your Password must be a minimal 6 characters long'; } if ($_POST['password'] !== $_POST['confirm_pass']) { $errors[] = 'Your Passwords do not match, please make sure both passwords are the same!'; } if (filter_var($_POST['register_email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email adress is required'; } if(email_exists($_POST['register_email']) === true){ $errors[] = 'The email you provided is already in use. If you are having trouble remembering your user info click <a href="#">here</a>'; } if (!$resp->is_valid) { $errors[] = 'You need to enter a valid security code'; } } } <form name="register" action="register.php" method="post"> <tr> <td class="register_td_left2"><span class="">Security Code:</span></td> <td valign="middle" style="padding-left:2px"> <?php require_once 'recaptchalib.php'; $publickey = "6Lf5AeASAAAAAPue6LLdUDttmPDc-NbRandom"; // you got this from the signup page echo recaptcha_get_html($publickey); ?></td> </tr> </form> i left out most of the form , just to save some reading time for you guys. figure its of no importance. again i am puzzled as to why this doesnt work for me on this page, yet on the test page it works fine. please i have been stuck on this for far to long for such a simple thing. thanks.