PHP - I'm A New User Of Php Need Some Basic Help
<?php include "C:/php-login/ASEngine/AS.php";
if (! app('login')->isLoggedIn()) {
This php code is in a file called test.php and is on my drive Letter O in a sub directory called my old photos . I'm having a problems referencing the include back to the the path of where ASEngine/As.php which is on c drive . I have tried all different relative and absolute paths . Any help would be appreciated Thank You Similar TutorialsBasically, I'm still trying to wrap my head around OOP. What I'm trying to do here is a simple OOP user login script. But when I submit the form, all that happens is that the text fields reset them selves and nothing that I feel should be happening, happens. ie: I submit login data, and either it displays an error or reirects to index page. Neither happen, the form merely resets. Where am I going wrong? Code: [Select] <form name="loginform" id="loginform" action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <p> <label>Username<br> <input name="user" id="user_login" class="input" size="20" tabindex="10" type="text" /> </label> </p> <p> <label>Password<br> <input name="pass" id="user_pass" class="input" value="" size="20" tabindex="20" type="password"></label> </p> <p class="forgetmenot"><label><input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"> Remember Me</label></p> <p class="submit"> <input name="login" id="submit" class="button-primary" value="Log In" tabindex="100" type="submit"> <input name="redirect_to" value="/users.php" type="hidden"> </p> </form> Code: [Select] <?php if(isset($_POST['login'])) { $username = $_POST['user']; $password = $_POST['pass']; include("./classes/class.users.php"); USERS::login($username, $password); } ?> Code: [Select] <?php // Yes, my DATABAASE::DoIT(1) // (0) is working as intended (from a different include file) class USERS { var $user; var $pass; var $email; ////////////////////////////////////////////////////////////////////////////////////////////// function login($user, $pass) { include("/var/www/config.php"); DATABASE::DoIt('1'); $hashword = sha1($CONFIG['salt1']."$pass".$CONFIG['salt2']); $sql = "SElECT * FROM users WHERE username='$user' AND hashword='$hashword'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count==1) { while ($row = mysql_fetch_assoc($result)) { define('USERS_AUTHENTICATED', true); $_SESSION['USERS_username'] = $row['username']; $_SESSION['USERS_userid'] = $row['userid']; DATABASE::DoIt('0'); header("Location: index.php"); } } else { $_SESSION['loginError'] = true; DATABASE::DoIt('0'); return $_SESSION['loginError']; } DATABASE::DoIt('0'); } } ?> Basically this is a pretty straight forward application. The values are all best on a set of conditional statements held in a function and when the user presses submit, it SHOULD calculate the form....However, this is not the case, for some reason it keeps returning 0. I have tried and tried and tried....to no avail. I have attached the files so you can sort through a little easier as there are a good amount of lines. Thanks! [attachment deleted by admin] hi, i have made a website where people resgister their details of them and products. they have to enter the following details in form Name of company name of the product company address email id password mobile number contact and brief details about their company
user can then login with email id and pwd. now after login ..user will get a page where he can upload the photos of products images and their price, so now my question is that when he finishes uploading (|by clicking on upload button) the product images and price text box ..then on final uploaded webspage it should show all other things which he registerd before (company name , mobile number etc) along with images and price...hence the main question that user does not need to enter mobile and address while uploading images and filling proce ..but on the final page it should show mobile and address along with price and images..as user is not going to enter mobile and address again and again as he will have multiple products to upload.
I would appreciate your assistance, there are tons of login scripts and they work just fine. However I need my operators to login and then list their activities for the other operators who are logged in to see and if desired send their clients on the desired activity. I have the login working like a charm and the activities are listed just beautifully. How do I combine the two tables in the MySQL with PHP so the operator Logged in can only make changes to his listing but see the others. FIRST THE ONE script the member logges in here to the one table in MSQL: <?php session_start(); require_once('config.php'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $login = clean($_POST['login']); $password = clean($_POST['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); if($result) { if(mysql_num_rows($result) == 1) { session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: member-index.php"); exit(); }else { header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> ................................................. ................................ Now I need the person who logged in to the table above to be able to make multiple entries to the table below <? $ID=$_POST['ID']; $title=$_POST['title']; $cost=$_POST['cost']; $activity=$_POST['activity']; $ayear=$_POST['aday']; $aday=$_POST['ayear']; $seats=$_POST['special']; $special=$_POST['seats']; mysql_connect("xxxxxx", "xxx350234427", "========") or die(mysql_error()); mysql_select_db("xxxx") or die(mysql_error()); mysql_query("INSERT INTO `activity` VALUES ('ID','$title', '$cost','$activity', '$aday', '$ayear', '$special', '$seats')"); Print "Your information has been successfully added to the database!" ?> Click <a href="member-profile.php">HERE</a> to return to the main menu <?php ?> Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after Hi, so far I have managed to set up a somewhat basic login website with a mysql database backend. Once they have logged on they go to a "main menu" page. What I need to define is that user A sees button A but only that button, etc. (Then of course that same rule would have to apply if they tried to directly go to the page, but I am guessing I can do that in the same way that I currently do to force a login). If anyone has any tutorials or sample code I would much appreciate it. Thanks, Hi guys, I am trying to put together a little system that allows users to log onto my website and access there own personal page. I am creating each page myself and uploading content specific to them which cannot be viewed by anyone else. I have got the system to work up as far as: 1/ The user logs in 2/ Once logged in they are re-directed to their own page using 'theirusername.php' Thats all good and working how I need it too. The problem I have is this. If I log onto the website using USER A details - I get taken to USER A's page like I should but - If I then go to my browser and type in USERBdetails.php I can then access USER B's page. This cannot happen!! I need for USER A not to be able to access USER B profile - there is obviously no point in the login otherwise! If you are not logged in you obviously cannot access any secure page. That much is working! Please find below the code I am using: LOGIN <?php session_start(); function dbconnect() { $link = mysql_connect("localhost", "username", "password") or die ("Error: ".mysql_error()); } ?> <?php if(isset($_SESSION['loggedin'])) { header("Location:" . strtolower($username) . ".php"); if(isset($_POST['submit'])) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $mysql = mysql_query("SELECT * FROM clients WHERE username = '{$username}' AND password = '{$password}'"); if(mysql_num_rows($mysql) < 1) { die("Password or Username incorrect! Please <a href='login.php'>click here</a> to try again"); } $_SESSION['loggedin'] = "YES"; $_SESSION['username'] = $username; $_SESSION['name'] header("Location:" . strtolower($username) . ".php"); } ?> HEADER ON EACH PHP PAGE <?php session_start(); if(!isset($_SESSION['loggedin'])) { die(Access to this page is restricted without a valid username and password); ?> --------------------------------------------------- Am I right in thinking it is something to do with the "loggedin" part? The system I have here is adapted from a normal login system I have been using for years. The original just checks the details and then does a 'session start'. This one obviously has to re-direct to a user specific page. To do this I used the <<header("Location:" . strtolower($username) . ".php");>> line to redirect to a page such as "usera.php" or "userb.php" Any help would be greatly appreciated! Ta Hi, I am getting frustrated beyond belief at the moment with trying to get a very simple script to run, I am using PHP 5.3.3 and MySQL 5.1 on a Win2k8 server with IIS7.5. Basically my script is connecting to a local database, running a single select query, returning those rows and building up a string from them. The problem is that I am receiving complete BS responses from PHP that the access is denied for the user being specified. This is complete rubbish since the user can connect via mysql, sqlyog, ASP.NET MVC without issue but for some bizarre reason it is not working via PHP. The code for the script is here : Code: [Select] <?php $mysql = mysql_connect('127.0.0.1:3306', 'myuser', 'mypass', 'mydatabase'); if (!$mysql) { die(mysql_error()); $content = "<nobr></nobr>"; } else { $result = mysql_query('SELECT * FROM tblEventGroup'); $content = "<nobr>"; if ($result) { while($row = mysql_fetch_assoc($result)) { $content .= "<span>"; $content .= $row['GroupName']; $content .= "</span>"; $content .= "<a href=\"../Event/EventSearch?groupid="; $content .= $row['GroupId']; $content .= "\" target=\"_blank\">Book here</a> "; } } mysql_close($mysql); $content .= "</nobr>"; } ?> I cannot for the life of me understand what the problem is, the return error is Access denied for user 'myuser'@'localhost' (using password: YES) Hallo everybody,
i have the following code.
but i get allways this error while the user exist in the database.
User not found!
what do i do wrong?
thank you very much for your help
Rafal
<html> <head> <?php $connection = mysql_connect("db.xyz.com", "username", "password") or die ("connection fehler"); mysql_select_db("db0123456789") or die ("database fehler"); $email = $_POST["inp_email"]; $pwd = $_POST["inp_pwd"]; if($email && $pwd) { $chkuser = mysql_query("SELECT email FROM gbook WHERE email = '($email)' "); $chkuserare = mysql_num_rows($chkuser); echo $email; echo $pwd; if ($chkuserare !=0) { $chkpwd = mysql_query("SELECT pwd FROM gbook WHERE email = '($email)' "); $pwddb = mysql_fetch_assoc($chkpwd); if ($pwd != $pwddb["pwd"]) { echo "password is wrong!"; } else { echo "login successed"; } } else { echo "User not found!"; } } else { echo "Pleas enter your email and password!"; } mysql_close($connection); ?> </head> <body> <form action="login.php" method="post"> Email <input type="text" name="inp_email"><br> Password <input type="text" name="inp_pwd"><br> <input type="submit" name="submit" value="login"> </form> </body> </html> Edited by rafal, 21 September 2014 - 04:33 PM. Hello, i've got some shop script which has 2 payment modules which i'd like to use for something else, the payment modules only work if the user is logged in though, i tried to make them standalone scripts but that didn't work out too well. So now i decided to go another way and just let everyone have the same session so everyone will be using the same username&password automatically. the index file looks like this: Code: [Select] <?php include('./inc/config.php'); include('./inc/functions.php'); include('./lang/'.$language.'.lng'); $id = addslashes($_REQUEST["id"]); $user = addslashes($_REQUEST["username"]); $pass = addslashes($_REQUEST["password"]); $language = strtolower($language); if(empty($id)) $id =1; $file = mysql_query('SELECT * FROM navi_'.$language.' WHERE id="'.$id.'"'); if(mysql_num_rows($file)>0) $file = mysql_fetch_array($file); else $file = mysql_fetch_array(mysql_query('SELECT * FROM navi_'.$language.' WHERE id="404"')); if(!empty($user) AND !empty($pass)) {$query = mysql_query('SELECT * FROM users WHERE username="'.$user.'" AND pass="'.md6($pass).'"'); if(mysql_num_rows($query) == 1) {$_SESSION[$session_prefix."user"] = ucfirst($user); echo'<meta http-equiv="refresh" content="0; url=index.php?id=8">';} else $error = 'Username oder Passwort ist falsch.';} include('./designe/'.$designe.'/head.tpl'); include('./designe/'.$designe.'/navi.php'); include('./designe/'.$designe.'/middle.tpl'); if(file_exists('./pages/'.$file["file"])) {echo'<h1>'.ucfirst($file["title"]).'</h1>'; include('./pages/'.$file["file"]);} if(!empty($error)) echo '<font color="red">'.$error.'</font>'; include('./designe/'.$designe.'/foot.tpl'); ?> Now i tried alot of things including adding: Code: [Select] session_start(); $_SESSION["username"] = "peter"; $_SESSION["user"] = "peter"; $_SESSION["id"] = "1"; $_SESSION["pass"] = "peter"; $_SESSION["password"] = "peter"; or Code: [Select] $id = "1"; $user = "peter"; $username = "peter"; $pass = "peter"; $password = "peter"; also a combination of both, nothing works, but i don't understand why ? Any help is appreciated. /Edit, i tried adding it to the paymentmodule .php aswell, but no luck. Hallo everybody,
the user is in the table, but i get error (user not found!).
thank you very much for your help
Rafal
<!DOCTYPE html> <html> <head> <title>index</title> <meta http-EQUIV="CONTENT-LANGUAGE" content="en"> <?php SESSION_START(); include("abc.php"); $link2 = mysqli_connect("$hoster", "$nameuser", "$password", "$basedata") or die ("connection error" . mysqli_error($link2)); $email = $_POST["inp_email"]; $pwd = $_POST["inp_pwd"]; if($email && $pwd) { $chkuser = mysqli_query("SELECT email FROM $table2 WHERE email = '$email' "); $chkuserare = mysqli_num_rows($chkuser); if ($chkuserare !=0) { $chkpwd = mysqli_query("SELECT pwd FROM $table2 WHERE email = '$email'"); $pwddb = mysqli_fetch_assoc($chkpwd); if (md5($pwd) != $pwddb["pwd"]) { echo "Password is wrong!"; } else { $_SESSION['username'] = $email; header ('Location:list.php'); } } else { echo "user not found!"; } } else { echo "enter your Email and Password!"; } mysqli_close($link2); ?> </head> <body style="font-family: arial;margin: 10; padding: 0" bgcolor="silver"> <font color="black"> <br> <form action="index.php" method="post"> <b>Login</b><br><br> <table width="100%"> <tr><td> Email:<br><input type="text" name="inp_email" style="width:98%; padding: 4px;"><br> Password:<br><input type="password" name="inp_pwd" style="width:98%; padding: 4px;"><br> <br> <input type="submit" name="submit" value="Login" style="width:100%; padding: 4px;"> </td></tr> </table> </form> </font> </body> </html> hello. I need your help please. I'm building logistics website with user panel and admin panel. I've done all login and register forms. now I want to : admin can add package with: tracking number , weight , cost , and declaration form. user can fill declaration form after admin add package to user panel. then admin can see the declared form. is it possible in php? thank you in advance I'm trying to create a website so that if I go to http://websiteaddress.com/, it will go to then index and if you are already logged in it will display the main page, but if you aren't logged in it'll show a login/registration page. Also, how does the following work: index.php?action=home index.php?action=register They show two seperate pages? So, could it go to the home page if logged in, but if not logged in it'll go the registration/login page? I have 3 tables (sectors, subsectors, and business). From the site a site user can select a sector, which then lists the subsectors, then when they select a sub sector they can view a list of the businesses within the selection. I am trying to remove a step so that they will see the sectors and be able to select, then will list the subsectors with the business names under the subsectors. The code I have is prior to removing the step is ...... Code: [Select] <?php $rs=mysql_query("select * from tblmain WHERE id='$view'"); while($row=mysql_fetch_row($rs)){ foreach ($row as $k => $v){ $row[$k] = nl2br($v); } echo("<h4>" . $row[1] . " Sectors </h4>"); } ?> <ul> <?php $pnds=1; if (isset($_GET["id"])) $pnds=$_GET["id"]; $sql = "select * from tblsub WHERE catid='$view' ORDER BY subsec "; $reccount=$sq->numsrow($sql); if ($reccount > 0) { $ata =$sq->query($sql); while($rs=$sq->fetch($ata)) { ?> <li><a href="listings.php?view=<?php echo $rs["subsec"];?>"><?php echo $rs["subsec"];?></a></li> <?php } } ?> </ul> I have tried to get this to work but the problem I am having is $view is an number but the actual business table is not id, it is by subsector name. I have tried ....... Code: [Select] <?php $rs=mysql_query("select * from tblmain WHERE id='$view'"); while($row=mysql_fetch_row($rs)){ foreach ($row as $k => $v){ $row[$k] = nl2br($v); } echo("<h4>" . $row[1] . " Sectors </h4>"); } ?> <ul> <?php $pnds=1; if (isset($_GET["id"])) $pnds=$_GET["id"]; $sql = "select * from tblsub WHERE catid='$view' ORDER BY subsec "; $reccount=$sq->numsrow($sql); if ($reccount > 0) { $ata =$sq->query($sql); while($rs=$sq->fetch($ata)) { ?> <li><a href="listings.php?view=<?php echo $rs["subsec"];?>"><?php echo $rs["subsec"];?></a></li> <?php $rs=mysql_query("select * from tblbusiness WHERE category='$view' ORDER BY name"); while($row=mysql_fetch_row($rs)){ foreach ($row as $k => $v){ $row[$k] = nl2br($v); } print(" . $row[2] . "); } <?php } } ?> </ul> But obviously category is by name and not $view which is an id. Any help would be greatly appreciated. Does it matter where you start your session at? Does it have to be before the <!doctype> tag or can it go anywhere in the page? I am quite new to php and the mvc setup, I am developing a library app however starting at the very basics so as not to become overwhelmed!
I am trying to do a basic insert to my book table, this is the code I have so far alsong with the error I am presented with.
Model (models > adminarea_model.php)
adminarea_model.php
public function create($title_text) { $title_text = strip_tags($title_text); $sql = "INSERT INTO book (title) VALUES (:title)"; $query = $this->db->prepare($sql); $query->execute(array(':title' => $title_text)); $count = $query->rowCount(); if ($count == 1) { return true; } else { $_SESSION["feedback_negative"][] = FEEDBACK_NOTE_CREATION_FAILED; } return false; } Hello,
I hope I picked the right category.
I have an interesting situation. I'm building a website and I want to have the ability to work on it / prototype it without having the website accessible to the public. Currently it's not accessible because I placed a .htaccess file into my server but I think it didn't work correctly because I can't actually log in. That's not the main problem, I think the problem is that it's not ASCII but UTF-8. Been trying to figure out how to convert that.
I'm not sure if I even need web but I figure if I'm going to test it, which one of the things I have to test is capturing video with my phone then storing it to my server then retrieving it again. The capturing should be easy through HTML5 from what I've read.
I have access to php and sql. I just don't know if I need internet access. I don't know how to store locally.
Most php scripts don't even seem to mention a storage location. I have set up sql databases that used php to gather information. It's just not fresh in the mind at the moment.
I mean it had to work right? I mean I get the pop up that says "Authentication Required" which wasn't there until I uploaded the .htaccess file, which how can the .htpasswd file not be read if the .htaccess file is being read. I think it is in the right folder... anyway, maybe I don't need the web to prototype my website
Except for the phone part, I would like to see that the phone's camera UI and camcorder UI is easily accessed by one button
Any help would be appreciated
is it okay to name a column "date" in a table ??? just want to know whether this could mess up everything thanks in advance |