Jump to content

Php.ini file?


Html

Recommended Posts

  • Replies 97
  • Created
  • Last Reply

Top Posters In This Topic

You may or may not have access to it depending on the nature of your account.  I suggest that you contact your host.

If you do not have access to the file, there is a good chance that you can change the setting of interest dynamically.  Further, if it is a setting that you wish to use repeatedly, then you should follow Dsonesuk's suggestion below.

Another way to discover the location of the file and thus avoid having to contact your host is to run the phpinfo( ) function on your host server.  This will tell you everything that you can know about the PHP processor running on your host's server.

Roddy

p.s.  If you find my answer helpful, then hover over the heart, find the trophy, and click.  Thanks after the fact, is better than than thanks before it.

Edited by iwato
Adjustment to new information provided by Dsonesuk.
Link to comment
Share on other sites

They probably won't let change the server php.ini file, mainly to prevent members mucking it up, but you can place a custom php.ini in the root directory of your site which will override the default settings, so if any mishap should happen the untouchable php.ini remains safe as backup.

Settings can be altered using .htaccess as well.

Link to comment
Share on other sites

I see, the reason I need to change this is I downloaded a new login system, that fortunately works and is up to date compared to what I was using last month. Available on youtube, the tutorial, and the source, so I edited the files according to what I need. I now need to get a confirmation email to be sent to an email once an account has been registered.

The alternative could be to remove this feature, due to what has been stated in the above posts.

Once registered, and auto logged in, there is a link to click, which doesn't lead anywhere. I think verify.php is the file to get that working, as for the login part where the link is, one of the other files, I think it would be register.php

    // Add user to the database
    if ( $mysqli->query($sql) ){

        $_SESSION['active'] = 0; //0 until user activates their account with verify.php
        $_SESSION['logged_in'] = true; // So we know the user has logged in
        $_SESSION['message'] =
                
                 "Confirmation link has been sent to $email, please verify
                 your account by clicking on the link in the message!";

        // Send registration confirmation link (verify.php)
        $to      = $email;
        $subject = 'Account Verification ( clevertechie.com )';
        $message_body = '
        Hello '.$first_name.',

        Thank you for signing up!

        Please click this link to activate your account:

        http://localhost/login-system/verify.php?email='.$email.'&hash='.$hash;  

        mail( $to, $subject, $message_body );

        header("location: profile.php"); 

    }

    else {
        $_SESSION['message'] = 'Registration failed!';
        header("location: error.php");
    }

}

So that bit there, about verifying, I guess replace that register.php code with something else to get to a profile index, it won't be the index.php since that is the register and login form. It is a quite a nice setup. It was nice somebody setup such a modern and well design login system.

I could may be just remove that bit, it is on the register.php, so that sort of becomes a Thanks for registering page once done, then from there, a comment box to post comments, now that requires a new mysql database according to another video tutorial which is about making a comment box for a user.

Edited by Html
Some more thought about the page code
Link to comment
Share on other sites

According to another video on the that site, to get an email confirmation sent to a user's email, it requires editing a file.

But I'm thinking may be to edit the php code, which I imagine is the bottom part there, and once registered just login to a user's index, and from there can logout, post a comment to the user accounts index. I believe that would require another separate mysql database?

Link to comment
Share on other sites

According to another video on the that site, to get an email confirmation sent to a user's email, it requires editing a file.

That's not true.  There's one way you can do it using the mail function and setting default values for various things in php.ini, but that's not the only way that PHP can send email.  You could use a library like PHPMailer to give you a lot of features pretty easily, for example.  The regular mail function can be a little difficult to use in some situations.

I believe that would require another separate mysql database?

You shouldn't need more than one database, there aren't a lot of limitations on a database that would mean you need a second one.

Link to comment
Share on other sites

  • 3 weeks later...

 

I did try a tutorial on how to add a comment box into a profile.php file, once registered using a registration.php file that is from the login system. That hasn't worked, just leads to a 404. Sent a message to the tutorial creator, hopefully may be a few pointers. I think it could be the way it works, or may be I've done something wrong, but I can't think what. I've typed up what he narrated, the clip is from just over two years ago, pretty recent.

Requires adding in a include connect.inc.

This is a comments.inc file

<?php
function setComments(){
if  (isset($_POST['commentSubmit'])){
$uid=$_POST['uid'];
$date=$_POST['date'];
$message=$_POST['message'];

$sql="INSERT INTO comments"(uid, date, message) VALUES('$uid, $date, $message);
$result=mysqli_query($conn, $sql);

   }
}
<?

 

And this below is the profile.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'];
}

date_default_timezone_set('Europe/London');
include 'comments.php.inc';
include 'db.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>
          
          <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>

 

As for the confirmation email. So what can I do to get that going?

Edited by Html
Link to comment
Share on other sites

I didn't notice that, unfortunately that hasn't change the result, still a 404 loads.

Really shouldn't the comment be sent to the database, and not go to another page.

I also change db back to connect.inc. since that is what it was, nothing.

Edited by Html
Link to comment
Share on other sites

If I was you, I would carefully look through this code AGAIN! I'm not surprised it doesn't work!

Misplaced closing/opening php tags, mixed long/short code tags (does your server settings even allow short tags? <?=...?>), missing '$' from beginning of variable, session_start(); should be at very top of page before anything else.

Link to comment
Share on other sites

The top is included, I just copied it incomplete yesterday.

As for the code, I don't know, I just added in that code from that tutorial into another code from another tutorial's login system file.

Link to comment
Share on other sites

Your right! couldn't have anything to do with code....but wait! maybe it does

<?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>";

 

Link to comment
Share on other sites

Minus the unnecessary juvenile sarcasm, if you're seeing something like "setComments" in the URL and you're wondering why that's a 404, the browser is asking the server for a file with that name on it.  If you don't have a file with that name, the server is going to respond with a 404.  This is completely separate from anything you are doing in the code: if you ask the server for a file, and the server doesn't see that file and doesn't have a way to serve that resource, it responds with a 404.  It's as simple as that.  Once you identify that you're asking the server for the wrong URL, then you can figure out why it's not finding your URL.  Maybe you're not giving it the correct URL, or maybe you haven't set up the server correctly.

Link to comment
Share on other sites

So to be clear! it IS something to do with the code then, right!

Insofar as an incorrect URL was typed in the code?  If you want to look at it like that, I guess you can.  Insofar as it is some sort of runtime error or other bug?  No, it's a misunderstanding of how the server works.

No there is no setcomments page or anything, according to the video tutorial that was the man explained it.

That was kind of rough to watch, so I didn't continue to see if he eventually returns a value from that function.  But the major difference between what he shows and what you did is that the ran the function, and you just wrote the name of it.  Syntactically, the difference is whether you include parentheses after the function name.  You didn't.  A bigger issue is why he thinks it's necessary to call a function to return the action of a form.  If that is going to work, then the function should return the URL that the form should submit to.  From your code above it looks like you're trying to tell it to run that function when the form submits though, but that's not how you do that.  Like I said, I didn't watch the entire video but that guy may be just as confused on how this stuff works.

If you want to call a function when you submit the form, have it submit to the same page but pass another value telling it which function to run.  That is not the usual way to do this though, the usual way to do this is to give it the URL of your form processing page (which could be, and usually is, the same URL that displays the form), and on that page you check if the form was submitted and, if so, process the submitted data.  In your case, that would mean checking if something like one of those hidden inputs is set in the $_POST array.  If it's set, then consider the form submitted and try to get the data, validate it, and either show error messages or do whatever you want with the valid data.  The w3schools site and several other sites online have a lot of information on how to use PHP to process form data, it's one of the most common things you'll do with PHP.

Link to comment
Share on other sites

So basically, the current CODE is trying trying to implement a function wrongly referenced in action attribute of form, which if succeeded would insert data into database only! With action attribute remaining blank, meaning it would return to the same page on submission.  But! Whose current CODE will only produce a error, because of extra opening php start tag ( be it shorthand) and as previously mentioned in topic before, wrong syntax CODE for inserting into database.

So the CODE, if corrected would not have produced a 404 error, SO all to do with CODE!

Link to comment
Share on other sites

Basically, no, that's wrong.  The action will not be blank, PHP will see "setComments", assume it is an undefined constant, and use the string "setComments" as the action for the form.  That's the reason for the 404.  That's not a typo in the code, that's a fundamental misunderstanding about how the request/response cycle interacts with PHP.  You don't use a PHP function for the form action, you use a URL.

Whose current CODE will only produce a error, because of extra opening php start tag ( be it shorthand) and as previously mentioned in topic before, wrong syntax CODE for inserting into database.

If there's a syntax error, why do you suppose OP is receiving a 404 instead of a 500?  I see the short open tag, and I bet that was not copied and pasted.  If it were actually in the original code, the outcome would be different.

So the CODE, if corrected would not have produced a 404 error, SO all to do with CODE!

Yeah?  You think you can just write the name of a PHP function which does not correspond to a file on disk or rewrite rule as the form action and that's going to work well, huh?  You're thinking that this Youtube tutorial is being followed because OP has a good understanding of how PHP works?

Maybe drop the attitude and address the actual problem and help the person learn.  If you're here just to argue with me, you're in the wrong place.  We're here to help, not pick apart sentence meaning and engage in petty argument.

Link to comment
Share on other sites

Okay,

While leaving the comment insert task aside,

With having created an account, how would the comment be sent to the user's index page? As there isn't one at the moment. I think the video tutorial further sort of explains this, there are two more videos after that one there. But obviously, without a comment being sent to the database, it is too early for that step.

 

<?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'];
}

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>
          
          <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>
    

</body>
</html>

 

Edited by Html
Added profile.php code
Link to comment
Share on other sites

Errr Yeah! i kinder pointed it and other mistakes, it seems, to be there to run a function, weird i know, but if it was called as a function it would not be treated as a string text 'setComments' and used for link to none existent page causing the 404 error. IE THE CODE IS THE PROBLEM. From the code supplied there's no variable of that name, only the function.   So it seem strange to name a variable exactly as a function?  This is the only conclusion I can I came up with, that its referring to a function. I don't know if it is how the video show how to do it, or the op just copying pasting different code from different sources hoping for it work. BUT! having the code fit for purpose, fixing all the CODE errors, however bad it is, would have it working.

Link to comment
Share on other sites

I'm just going to ignore the pedantry enthusiast.  Yeah, "the code is the problem", OK, great.  Now let's solve the problems, both with the code and the misunderstandings about how PHP works.

For the user's page, if you want only each user to see their own page, then you can just get their user ID from the session.  If you want any user to be able to see any other users' page, where they might have a public profile or something, then you pass the user ID through the URL, e.g. profile.php?user=10.  You can get that and look up the user information from your database, including the comments.  When you save the comments in the database one of the fields needs to be the user ID for the user who the comment is for (you can also store the author user ID).  The IDs in your database should link everything together, the unique IDs are what you use to create the links between database tables and objects.

Link to comment
Share on other sites

Hmm, right..

Okay, well I decided to leave the whole confirmation email feature out, therefore there are linking bits of that in the profile.php up there.

As for linking a comment with a particular name for a profile index page. Well the database has one id 1, so therefore a name with that. So id 1 in my sql db has to be linked for one profile page, as you state above. I don't have a page for it, I doubt this login system creates an index page for a user, it uses both a first name and surname, so no actual user alias. I suppose have a profile link in the kind of control panel with the textbox there, so the user clicks on that to load a profile page.

As for the comment database task. Not sure about that. The login system is separate as I stated from that other youtube user's stuff, I'm sure a bit of code here and there it should be okay..

Link to comment
Share on other sites

Sure, you can make the link whatever you want.  They don't need a username or something, they just need a unique ID in the database.  That should be the primary key on the users table, and I make those auto-increment integers, so they're just numbers.  Even if I do have a username or some other unique identifier, I still use a numeric primary key ID in case someone wants to change their username, and because it's smaller to store a bunch of numbers than a bunch of text.  If someone changes their username I don't have to go through my whole database and change their username everywhere, because the only place that stores it is the actual users table, along with their numeric ID.  That numeric ID is stored in the other tables to link records to that user, so when their username changes their ID stays the same and I don't have to change any other tables.  And, again, it takes less space to store a single integer than a username of X characters (as long as X is greater than 4 or 8, depending on your server).

They don't need a username or whatever else to make a profile page though, just a way to uniquely identify any user.  The primary key ID is the way to do that.

In general, don't worry about adding all these features at once.  Get the basics down, like how to process a form and how to interact with the database.  For the other features you want, you can break any feature down into smaller and smaller pieces until each piece is small enough to have a simple solution, and then you combine them together to build your bigger feature.  That goes for something like email confirmation - one part is them registering their account (which you can break down into smaller pieces), another part is sending the actual email, another part is them clicking on the confirmation link where you update the database, etc.  Each of those is a small piece with a simple solution, and you put them together you build your bigger feature.  The same concept can apply to any feature or fixing bugs in general.

I don't have a page for it, I doubt this login system creates an index page for a user

None of them do, you don't create new files for each user.  You have a single PHP script which can display the profile for any user which you tell it to, from the unique ID for that user.  You can add authentication and authorization there if you want, so that you have to be logged in to look at other profiles, or maybe there's a permission system where you can look at certain profiles but not others, etc.  But all of that is handled in a single PHP file, there isn't an extra copy for each user or whatever.

For the comment stuff, just break it down.  One part is creating the actual form and getting it to submit to a PHP page.  Another part is creating that PHP page where it gets the data from the form, maybe the only thing you do is print it out to verify it.  Then you can validate the data and show error messages if necessary.  Then add it to the database.  Each of those steps is a smaller piece with an easier solution than trying to think of the entire thing as one problem you need to solve.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...