Jump to content

Html

Members
  • Posts

    640
  • Joined

  • Last visited

Everything posted by Html

  1. And yes I did try that too. Also this affects the CSS on the page too. I tried placing that code in the first part, like so. <?php /* Main page with two forms: sign up and log in */ require 'db.php'; session_start(); ini_set('display_errors', 1); error_reporting(E_ALL); ?> That has solved that problem, and then this was displayed after registration. mysqli::escape_string(): Couldn't fetch mysqli in line 12 and 18 in register.php I guess this is line 12 $first_name = $mysqli->escape_string($_POST['firstname']); and 18 $result = $mysqli->query("SELECT * FROM users WHERE email='$email'") or die($mysqli->error());
  2. I tried that for index.php, it doesn't load anything once done, This is all it loads after registration. ini_set('display_errors', 1); error_reporting(E_ALL); I have a feeling it must be the free host, because nothing has changed between the paid host, and the free host. Not sure what I am using, all I know is I got the files from that video tutorial as a start really, after the previous video one didn't go any further.
  3. Well having recall my previous posts, you'll know i'm not very good at web languages. From what I can remember, the php settings are the same as the previous free website host I did use, and the paid host. I have a feeling that free host I am using is may be a reseller account from fasthost web hosting. It only has ads on the cpanel area. As for the error code, I have the index so index.php <?php /* Main page with two forms: sign up and log in */ require 'db.php'; session_start(); ?> <!DOCTYPE html> <html> <head> <title></title> <?php include 'css/css.html'; ?> </head> <?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'; } } ?> And then, what other code would be needed to determine errors? Thank you.
  4. Index.php is the link in the address bar after registration. So it should of been profile.php after. As for checking errors, I don't remember about that.
  5. Hi, I am using a free website host to display a login/registration system, the exact same one as the one I am using on a paid service. For what ever reason the free host doesn't seem to store any registered data. I'm using the same php files, there isn't anything different, since they are from the same setup. The php version on the free host is 7. I checked both mysql setting pages, I don't know what is the problem with this. If it worked on the other free host I was using months ago, but I closed that account due to pop up ads, this free host doesn't put any on a page. Thank you.
  6. Unlikely, that anyone gaining access to accounts would be possible, since a lot of free services are now designed with features that don't make it easy as it may of been, like ten years ago for anyone to login to an account. But yes, certainly if a site is going to be online 24/7 should have some kind of encryption, or hash, the examples files I have from the youtube video tutorial I got from, which went nowhere had a basic hash use.
  7. Html

    Php.ini file?

    My web connection only returned today. No I don't get much of what is going on with Php, I'm not able to go forward with this. May be I don't have a mind for language, may be the problem. The aim here is to get a profile page to link with a registered name, I don't know about the comment task just yet, I'll want to do that after. The profile page has a hyperlink as we can see in the code I've pasted above, <a href="profile.php?id=<?php echo $user_id; ?>"><button class="button button-block" name="View profile"/>View profile</button></a> So here I am again. At least with video I can learn something, but obviously you mean that I can't learn the theory, and the process of it all. In order to succeed with web languages or programming ones, it is necessary to know. I did sent a private comment to the video creator of the files I downloaded, so who ever it is, is still active with that video. Recent comments answered by the uploader.
  8. Html

    Php.ini file?

    For the moment, a registered name and a comment box internally, to post their comments, to appear on their own index, that is simply goal here. As for comment or sending messages to other profiles, I don't know how or what ever that is going to work out. As for the inc, that was from the tutorial, I left that out as the tutorial got to to a point where it went a different direction, so I decided to forget that, left this, as you can see, and then returned, and then left again, and now I'm back, over a week later have that book you suggested, and I can't make much out of it. So the profile index was a first easy step to get going, and I can't get that functioning. I even took a look at the first book I got. May as well not even have it.
  9. Html

    Php.ini file?

    There isn't any inc. That was from the tutorial you saw a little off, that leads to nowhere. Right, the profile link is the focus which would lead to the profile index, then the comment box for the registered name, which is what I would want, I don't mean a profile link to view another registered name's index. There wouldn't be any reason for that, since the db only has four, five names registered. Well I didn't really need to ask one, I'm still on the same subject. I'm going in circles here.
  10. Html

    Php.ini file?

    Right, What I have is a registration system, so the registration takes place, then there is the box that is available to post a comment, it doesn't go anywhere as there is no code for that. Then there is a link to the profile page, which should somehow create one for the least, with the result above, the profile? etc That is the focus here, now that has something to do with validation. <a href="profile.php?id=<?php echo $user_id; ?>"><button class="button button-block" name="View profile"/>View profile</button></a> <?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 } date_default_timezone_set('Europe/London'); include 'comments.php.inc'; include 'connect.inc.php'; ?> <!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>'; } ?> <?php echo "<form method='POST' Action='".setComments."'> <input type='hidden' name='uid' value=''> <input type='hidden' name='date' value='".date('Y-m-d H:M:S')."'> <textarea name='message'></textarea> <button type='submit' name='commentSubmit'>Comment</button> </form>"; ?> <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>
  11. Html

    Php.ini file?

    So once registered, the login must process validation? To then be able to post comments from that name, to the db and then some kind of get on the profile received the comments from a db. From viewing the book, Learn php, it just doesn't make sense to me, there isn't anything I can make of to get my task down. I read the chapter of validation, but yes I can't make much of anything from it.🤔 I tried youtube yesterday again for a video tutorial, so far nothing new, just the typical money ad revenue attempt videos I imagine. This is the login.php <?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"); } }
  12. Html

    Php.ini file?

    Hmm, I don't quite get the validate part. I did try and edit the active property in the mysql database, that doesn't do anything. From 0-1. I took a look at the video of the files I downloaded months back, so the narrator explained some basics of the code, login and logout, of course, he went through the verify.php, which explained about confirming an account. I of course have skipped that, I edited the profile page to remove the verify link so therefore I edited the active. But he was using a localhost to do the task, doesn't matter too much.
  13. Html

    Php.ini file?

    I had some idea it would be from the previous posts, Validate that how? Is this required? <?php session_start(); if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { //do nothing } else { $redirect = $_SERVER['PHP_SELF']; $_SESSION['redirect'] = $_SERVER['PHP_SELF']; header('Location: login.php?redirect=' . $redirect); /* header('Refresh: 5; URL=login.php?redirect=' . $redirect); echo 'You are being redirected to the login page!<br>'; echo 'If your browser doesn\'t support this, <a href="login.php?redirect=' . $redirect . '">Click here</a>'; */ die(); } ?>
  14. Html

    Php.ini file?

    So the $user_id= needs a link? Then the other user posted auth_.php I thought what is here there is fine, for this. When I read back, there is also this profile.php?id=
  15. Html

    Php.ini file?

    The user is id is 1, or 2, 3, and so on. So the code from the profile page has to get that from the database. Obviously I have got the form and all of that, via the package from a tutorial, its using what is there, trying to get that, and try and build on it, like with this task. This is the correct step. $user_id="1"; if ($_SERVER["REQUEST_METHOD"] == "GET") { if (isset($_GET["id"])) { $user_id=$_GET["id"]; }
  16. Html

    Php.ini file?

    In mysqli, there is a session field, states active 0, does 1 mean, a registered name is currently logged in? That is from the sql code of that login system I downloaded a few months back. `active` BOOL NOT NULL DEFAULT 0, As for the user Id, so once registered, the profile needs an index page, the link from the internal login doesn't work, I'm back to the problem with the profile page, I want one of those. In the previous post you stated, that I have to think in small parts, so a profile page displays posted info from a mysql db, data isn't sent to it, so how do I go about getting this profile page working, and a comment box working, which sends to the db. I'm stuck, I have that book, but its states one point, and then I'm reading what you've stated previously, I need some pointers.
  17. Html

    Php.ini file?

    $user_id=""; if ($_SERVER["REQUEST_METHOD"] == "GET") { if (isset($_GET["id"])) { $user_id=$_GET["id"]; } This is on profile.php As for sessions must a 0 be 1, if logged in, on the mysql db?
  18. Html

    Php.ini file?

    How do I do that then? I've pasted the code examples, of what I have, this book explains in chapters information about php, and what each example does, but I don't get the whole relation to what I have. This is one of the reasons I would of preferred video, but that isn't an option for the moment. The more I think about this, it seems like I'm only going to get as far as getting a profile to send comments to an index, I'm going to need some examples, I know that doesn't really help me.
  19. Html

    user agreement

    Web page generator is what you'd need, I guess. You don't have word?
  20. Html

    Php.ini file?

    I did get a copy of this book, I'm still not quite sure where to go. Like I've repeated in the past posts, I have a login system which obviously works, but what it doesn't do is send comments from a profile page, that would be an internal one, not an index of a profile. The chapters in the book have 7, and 8 Making web forms is 7, which I have one already, and 8 is remembering information and databases. 10 is cookies and sessions. It is still all meters apart to me.
  21. Html

    Php.ini file?

    I viewed Amazon UK for books, they aren't many there. Some are too expensive. When i was in college eleven years back, the course manager expressed that he was more of a visual learner, he wasn't good with website design, he was more into Visual studio, so VB.net, and Visual basic. It was one of those year courses, that teach a little theory, and some practical on networking like LANs, and all that sort of stuff. I couldn't go further with it, I was lucky to pass the course, as it required certain certificate results I didn't have. I then tried to keep at web design, back then just as youtube arrived, and visual basic, but I gave up on that, as time went along. There were other problems at the time, so it wasn't practical in the end. I feel like I'm at square one, I guess we all have genetic problems LOL, some manifest at some point or another. But I guarantee, nobody on that course I was on succeeded with IT, they just weren't the stereotypes, I could tell my course manager had no faith in them or eventually myself, as time went by. And some didn't even like the subject, it was just a try. When I was on the course before, the year before that, it was full of under achievers, so yeah, to go up the ropes, in subjects that require you know, somebody who works at facebook, or one of those infamous hackers out there, who may of been real great with languages, ended up dead because of their madness, and illegality. Bit off topic here. Right, so what should I do then, okay, what book would you suggest?
  22. Html

    Php.ini file?

    Sure, and I tried to get a comment section working, but the video tutorial didn't go into detail or something was a bit different, and it didn't work out. I then tried to get a profile.php to display that name once registered, like a link, that was the last task I tried with you and the other user gave me some points, but I couldn't that going, I don't know the theory, and there aren't any examples on youtube about this in particular, how to display a profile index of a registered name. That is going to be needed, once a comment is posted, as that is where they could be viewable, I guess they could be seen in the profile login section, but that isn't really the task.
  23. Html

    Php.ini file?

    I haven't touched any of this since I last posted here, I don't know what to do. I've read a little of those links, yeah I mean I need video, that is much better. As for the email link, and all that, I did remove that, so once registered, logged into profile.php it just has a textbox, and has a statement stating account created, which remains there. So from there, I want to be able to post to the registered name, now the profile.php requires a session for that user, that is obviously what is missing from the profile.php I pasted last month here. <?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 } date_default_timezone_set('Europe/London'); include 'comments.php.inc'; include 'connect.inc.php'; ?> <!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>'; } ?> <?php echo "<form method='POST' Action='".setComments."'> <input type='hidden' name='uid' value=''> <input type='hidden' name='date' value='".date('Y-m-d H:M:S')."'> <textarea name='message'></textarea> <button type='submit' name='commentSubmit'>Comment</button> </form>"; ?> <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> The bottom section was from the video example, so you can see that textbox area, that doesn't work goes to 404, but yeah, that was a problem. But the comments needed to go with the right name. There is also a verify php page, as you stated an email verification required more of a technical change that a web host wouldn't permit, so as stated I removed that part, I doubt that is still needed for my small task. <?php /* Verifies registered user email, the link to this page is included in the register.php email message */ require 'db.php'; session_start(); // Make sure email and hash variables aren't empty if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])) { $email = $mysqli->escape_string($_GET['email']); $hash = $mysqli->escape_string($_GET['hash']); // Select user with matching email and hash, who hasn't verified their account yet (active = 0) $result = $mysqli->query("SELECT * FROM users WHERE email='$email' AND hash='$hash' AND active='0'"); if ( $result->num_rows == 0 ) { $_SESSION['message'] = "Account has already been activated or the URL is invalid!"; header("location: error.php"); } else { $_SESSION['message'] = "Your account has been activated!"; // Set the user status to active (active = 1) $mysqli->query("UPDATE users SET active='1' WHERE email='$email'") or die($mysqli->error); $_SESSION['active'] = 1; header("location: success.php"); } } else { $_SESSION['message'] = "Invalid parameters provided for account verification!"; header("location: error.php"); } ?>
  24. Html

    Php.ini file?

    Well my task hasn't changed, I want a registration name which becomes an account profile to have it's own comment box to post to a db, which then displays that on a profile index page, along with a upload image feature. Eventually with the ability to have a message inbox, outbox system. Seems the correct path to go for the moment.
  25. Html

    Php.ini file?

    I had a look back at the example post there. This is the logout from the files I downloaded from a youtube clip a few months ago, it works, but doesn't login to a profile section, it logins for a confirmation, but I changed that to no longer have that, but I want for any new registration names which are the accounts, as I stated in the previous posts. This is the logout from the files. <?php /* Log out process, unsets and destroys session variables */ session_start(); session_unset(); session_destroy(); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Error</title> <?php include 'css/css.html'; ?> </head> <body> <div class="form"> <h1>Thanks for stopping by</h1> <p><?= 'You have been logged out!'; ?></p> <a href="index.php"><button class="button button-block"/>Home</button></a> </div> </body> </html> So this isn't included, this example is some sort of array, I'm going to need something like this to do what, connect with a sql database, which the numbers are lists int he db. $userArray = [ [5, 'wroxbooks', 'wroxbooks', 'wroxbooks@wroxbooks.com', '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>'], [11, 'thatbook', 'thatbookp', 'thatbook@thatbook.com', '<p>Fusce convallis, mauris imperdiet gravida bibendum, nisl turpis suscipit mauris, sed placerat ipsum urna sed risus. In convallis tellus a mauris. Curabitur non elit ut libero tristique sodales. Mauris a lacus. Donec mattis semper leo. In hac habitasse platea dictumst. Vivamus facilisis diam at odio. Mauris dictum, nisi eget consequat elementum, lacus ligula molestie metus, non feugiat orci magna ac sem. Donec turpis. Donec vitae metus. Morbi tristique neque eu mauris. Quisque gravida ipsum non sapien. Proin turpis lacus, scelerisque vitae, elementum at, lobortis ac, quam. Aliquam dictum eleifend risus. In hac habitasse platea dictumst. Etiam sit amet diam. Suspendisse odio. Suspendisse nunc. In semper bibendum libero.</p>'], [43, 'otherbook', 'otherbookp', 'otherbook@otherbook.com', '<p>Proin nonummy, lacus eget pulvinar lacinia, pede felis dignissim leo, vitae tristique magna lacus sit amet eros. Nullam ornare. Praesent odio ligula, dapibus sed, tincidunt eget, dictum ac, nibh. Nam quis lacus. Nunc eleifend molestie velit. Morbi lobortis quam eu velit. Donec euismod vestibulum massa. Donec non lectus. Aliquam commodo lacus sit amet nulla. Cras dignissim elit et augue. Nullam non diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In hac habitasse platea dictumst. Aenean vestibulum. Sed lobortis elit quis lectus. Nunc sed lacus at augue bibendum dapibus.</p>']]; if (isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) { foreach ($userArray as $key => $row) { if ($userArray[$key][0] == $_SESSION['user_id']) { $user_id = $key; } } }
×
×
  • Create New...