Jump to content

Html

Members
  • Posts

    640
  • Joined

  • Last visited

Everything posted by Html

  1. I did send an email to somebody who appears to be a website designer, so I hope he can at least respond to me, I tried with a different one, but nothing so far. Just so you know, the video tutorial files, lucky I still kept them, just in case somebody could edit the code on my behalf, now the user has setup a charging system, so $5 to get a download. 😉
  2. Well I still have the account but it scheduled for closure within two months. Is there anyone you can point me to? Any contacts? I did some searches, well there are some freelance offers, I've viewed a few sites, but these range from £79 to into the hundreds, I know a business would need to charge something to make a profit. Some free lance offers are under £20. I've viewed this odd site. http://www.alittlebitofsomething.co.uk https://www.freelancer.com Also found this interesting old topic from 2007. Just from viewing the website design offers, just ridiculous amount of money being charged, when one has wix, I have a free wix site for blender 3d. I had made a few demos, quite crappy, based of a film.
  3. Hmm, you saw the example, that worked but was completely out of date to use $_POST (iss <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['login'])) { //user logging in require 'login.php'; } elseif (isset($_POST['register'])) { //user registering require 'register.php'; } } ?> what ever else and all that. I've been posting the examples now for months. 🤔 Like I stated, there is infinityfree, it would be a start, an actual working login system to register, post comments on a user's page, and so on. All i can do is inquire. Where do you suggest I look to try and find somebody who can make something workable on a free host for me for free to begin with, once working I will see where I can go with this. I cancelled my paid host, I couldn't keep up paying loose cash for no progress. I may eventually return, but infinityfree was better than the other free host since there are no pop up ads, dodgy ads, like install flash player and so on. Unfortunately the example code above wouldn't work, so having something that works according to infinity would be the right step.
  4. Hmm, could you not use the tutorial files, and just type the up to date code? I would plan to use the CSS from the existing files I have. Anything small would be appreciated, I only state this query, since I haven't got a response from some random individual I contacted, may be the free offer wasn't of interest, how long would it take to create, an hour or two. Could be less if a person knows what they are doing. I may have to look elsewhere if nothing is possible.
  5. Not sure if you can, but would you mind giving ago at creating the basic login setup? You could use the free host infinityfree to setup a working system. Thank you.
  6. I guess so. I emailed somebody who knows some website design, may be they can produce something that I need for free if possible. See how it goes with it. I'm going nowhere with this, I'm going to keep being out of the loop with this.
  7. I honestly don't know, I got this from the website of the video creator. How would I get this to work with some sort of function?
  8. So what do I need to get this to work properly then? I thought these files would work as is.
  9. Hmm, I'm only using the files from the site of the youtube user, his video showed the examples working on his machine. So I'm going on the whim with this. Chapter 5 in the book goes into functions, but nothing like this. More a basic intro, nothing like this.
  10. No, I wouldn't know what you are pointing at with that question..
  11. You mean the config.php file from the files must have something more, what is in the code I posted is what it is from the tutorial, the one just above there is the code took from the php manual, nothing was working as you pointed out I needed to use one of the examples. Well, yes I notice I used another php tag. Okay now the login.php does display, but there is no login function. From index.php it goes to login.php <?php include_once("header.php"); ?> <section class="parent"> <div class="child"> <?php if (!func::checkLoginState($dbh)) { header("location:login.php"); exit(); } echo 'Welcome ' . $_SESSION['username'] . '!'; ?> </div> </section> <?php include_once("footer.php"); ?> index.php And login.php <?php include_once("header.php"); ?> <section class="parent"> <div class="child"> <?php if (func::checkLoginState($dbh)) { header("location:index.php"); } if (isset($_POST['username']) && isset($_POST['password'])) { $query = "SELECT * FROM users WHERE user_username = :username AND user_password = :password"; $username = $_POST['username']; $password = $_POST['password']; $stmt = $dbh->prepare($query); $stmt->execute(array(':username' => $username, ':password' => $password)); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($row['user_id'] > 0) { func::createRecord($dbh, $row['user_username'], $row['user_id']); header("location:index.php"); } } else { echo ' <form action="login.php" method="post"> <label>Username</label><br /> <input type="text" name="username" /><br /> <label>Password</label><br /> <input type="password" name="password" /><br /> <input type="submit" value="login" /> </form> '; } ?> </div> </section> <?php include_once('footer.php'); ?>
  12. Sorry, there is an ip address right next to the listed db, in the mysql section. I forgot about that. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); <?php /* Connect to a MySQL database using driver invocation */ $dsn = 'mysql:dbname=db;host=IP'; $user = 'usr'; $password = 'pass'; try { $dbh = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } ?> I tried the following, nothing will display.
  13. Right, so these PDO code is the new code for connecting to a db. Which example should I use, 1 or 2? 1 requires an ip address, from the looks of it. And then 2 states the following;
  14. Then it must be localhost, that is what I have used for the other file for the past five months.
  15. Sure, all that is there, the db has been there for months. I viewed the book for any info on database connection, but what I read was similar in the code there i've posted. I did try $dbh = new PDO('mysql:host=localhost;dbname=securelogin', 'root', ''); username, password, and database after the root. $dbh = new PDO('mysql:host=localhost;dbname= 'root', user', 'pass', 'db' '); So the table is users, it is all done, just how to get this all linked to get that login system displaying.
  16. Well these settings are on the current php files. <?php /* Database connection settings */ $host = 'localhost'; $user = 'username'; $pass = 'pass'; $db = 'db'; $mysqli = new mysqli($host,$user,$pass,$db) or die($mysqli->error); So what do I do to get the other files to display the login page.
  17. I did view a different tutorial, and was able to get a copy of the actual php files. It doesn't work on the paid host. The tutorial user did the php work on the localhost. I did fill in the details to connect to a db. Nothing displays. This is from the config.php <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $dbh = new PDO('mysql:host=localhost;dbname=securelogin', 'root', ''); ?> So localhost will be fine on the paid host, then root and what ever after should be, a username and a password right?
  18. I wouldn't be too concerned, I think this forum has always been without a certificate.
  19. Sure, which is fine. But I want to be able to have any user which could login to the site, so each needs its own index page. That would obviously be the purpose.
  20. The code in the examples files from that video tutorial showed the id code. $user_id=""; if ($_SERVER["REQUEST_METHOD"] == "GET") { if (isset($_GET["id"])) { $user_id=$_GET["id"]; } ///process profile to id retrieved } So once registered via register.php, the profile.php page code kicks in, which any user would have same page, but unique to the user. It won't be register five accounts and they all have the same profile of one name, that wouldn't make sense. <a href="profile.php?id=<?php echo $user_id; ?>"><button class="button button-block" name="View profile"/>View profile</button></a> This link above from profile.php would send a user to their own index page. <?php /* Displays user information and some useful messages */ session_start(); // Check if user is logged in using the session variable if ( $_SESSION['logged_in'] != 1 ) { $_SESSION['message'] = "You must log in before viewing your profile page!"; header("location: error.php"); } else { // Makes it easier to read $first_name = $_SESSION['first_name']; $last_name = $_SESSION['last_name']; $email = $_SESSION['email']; $active = $_SESSION['active']; } $user_id=""; if ($_SERVER["REQUEST_METHOD"] == "GET") { if (isset($_GET["id"])) { $user_id=$_GET["id"]; } ///process profile to id retrieved } ?> <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <title>Welcome <?= $first_name.' '.$last_name ?></title> <?php include 'css/css.html'; ?> </head> <body> <div class="form"> <h1>Welcome</h1> <a href="profile.php?id=<?php echo $user_id; ?>"><button class="button button-block" name="View profile"/>View profile</button></a> <br> <p> <?php // Display message about account verification link only once if ( isset($_SESSION['message']) ) { echo $_SESSION['message']; // Don't annoy the user with more messages upon page refresh unset( $_SESSION['message'] ); } ?> </p> <?php // Keep reminding the user this account is not active, until they activate if ( !$active ){ echo '<div class="info"> Account Created! </div>'; } ?> <h2><?php echo $first_name.' '.$last_name; ?></h2> <p><?= $email ?></p> <a href="logout.php"><button class="button button-block" name="logout"/>Log Out</button></a> </div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script> </body> </html>
  21. So clearly the code is the problem, some of it is out of date, not PDO or something. 🤔 I'm sure the existing stuff is okay to use, it needs tweaking, that is a start. You stated PDO in previous posts. There are two types of php interpretation from what I read in the php site pages the link above. So index doesn't appear to be the problem, yet somehow with register and login, they are the problem. Login needs to display a email registered user, profile.php which then needs to have an index page which must show from the db like the name of the user. The chapters in the book are heavy, and confusing. You know you'd think better quality code on youtube would actually bring those users good revenue, now that would may be getting rich quick. I can't see how any short term php project would get anyone any finances, it can't work. <?php /* User login process, checks if user exists and password is correct */ // Escape email to protect against SQL injections $email = $mysqli->escape_string($_POST['email']); $result = $mysqli->query("SELECT * FROM users WHERE email='$email'"); if ( $result->num_rows == 0 ){ // User doesn't exist $_SESSION['message'] = "User with that email doesn't exist!"; header("location: error.php"); } else { // User exists $user = $result->fetch_assoc(); if ( password_verify($_POST['password'], $user['password']) ) { $_SESSION['email'] = $user['email']; $_SESSION['first_name'] = $user['first_name']; $_SESSION['last_name'] = $user['last_name']; $_SESSION['active'] = $user['active']; // This is how we'll know the user is logged in $_SESSION['logged_in'] = true; header("location: profile.php"); } else { $_SESSION['message'] = "You have entered wrong password, try again!"; header("location: error.php"); } } May be this is missing or needs replacing. if (in_array($_post['meal'], $meals)) { $stmt = $db->prepare('select dish, price FROM meals WHERE meal LIKE ?'); $stmt->execute(array($_post['meal'])); $rows = $stmt->fetchAll();
  22. Okay I decided to view the Learning php book, <?php // $db= new PDO('sqlite:dinner.db') //check if meals $meals=array('breakfast','lunch','dinner') if (in_array($_post['meal'], $meals)) { $stmt = $db->prepare('select dish, price FROM meals WHERE meal LIKE ?'); $stmt->execute(array($_post['meal'])); $rows = $stmt->fetchAll(); if (count($rows) ==0) { print "No dishes available."; } else { print '<table><tr><th>Dish</th><th>price</th></tr>'; foreach ($rows as $row) { print "<table><tr><th>$row[0]</th><th>$row[1]</th></tr>"; } print "</tables>"; } } else { print "unknown meal."; } ?> This piece of code was form chapter one, which shows I guess, modern php on how to display from a db, that is what I wanted for displaying an account. or an index page of a registered name. So, then on chapter 7, there is example code of validating data. May be I can use the new code and edit the existing examples I have from the tutorial.
  23. Hmm. That is quite a perspective on the subject in hand. I don't know what to do really now. You state to try and do some small tutorials on processing data. The books are so much the problem, but it is the way they express everything, in a video you have something visually displaying what is going on, even though as you've stated a lot of these aren't good quality. So in the end a video series is unlikely, unless somebody creates one for the right reason. As for patching up the code there, well if you could in anyway get something going, but in the long run it won't serve much of anything. I could suggest the free host I use, may be you could tailor it to that. If you are up for it then may be. Otherwise forget it. Thanks.
  24. Well I've learnt something new then, so there setup is different, and the example code I have used since I got it, is poor quality. Do you think you could tidy any of it? You don't assist for free obviously. I'm going to have to may be call it quits if I can't go anywhere with this. I did take a look at the php book again 207 sessions and cookies. This was the tutorial I viewed in Feb, having learnt from the previous video I watched last year. I was able to edit some details. So the files are all there, if you wanted to may be make it work, the account creation system using what there is there, patch it up, I'd appreciate it. I want a comment box for each account once created to post to an index, as well the ability to upload an image. But I'd be happy with just the account creation working, so once registered the page works to login to what ever account is listed on the db. files from the uploader via site
  25. Hello funce, thanks for some input. Justsomeguy, I downloaded what I have from a video tutorial. So I don't know about PDO, I'm just editing what there was there. As for the paid host, there is no difference between the two, technical side I'm sure there is. But if the other free host worked to get a registration for the least, as well as my paid host, then why this problem on this free host. How can I be something wrong, there is no difference in the php, its all the same crap. As for the account registration validating stuff, I never got that far with that. Could be the code I am using just is too basic for anything really serious. But then again I doubt that was really the problem even though you stated the way I was going about trying to get this tutorial to go one way and then hopefully another would add to it, and all that. I tried rereading the book I have, but I don't get it. I need a proper know how video tutorial, and there isn't anything like that yet.. I'm checking out this host since I can't keep continuing to have a paid host as much as I want to keep it. Free hosts are usually rubbish with their pop up ads, this how ever is nice. Just too nice to be true I guess. May be I should contact the free web host try and see if they can check out their php setup.
×
×
  • Create New...