Results 1 to 8 of 8

Thread: Convert to PHP5.3

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2012
    Posts
    81

    Question Convert to PHP5.3

    Can someone convert this to php5.3
    admin.php
    Code:
    <?php
    session_start();
    if(!session_is_registered('myPass')) {
    
    	header("location:index.php");
    }
    
    ?>
    check.php
    Code:
    <?php
    $myUsername=$_POST['myUsername'];
    $myPass=$_POST['myPass'];
    
    if ($myUsername==("Admin") & $myPass==("Pass") ) {
    
    	session_register('myUsername');
    	session_register('myPass');
    	header("location:admin.php");
    
    }
    else echo 'Something went wrong';
    
    ?>
    Last edited by vmen; Oct 30th, 2012 at 02:33 PM.

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Convert to PHP5.3

    This is untested but should work.

    php Code:
    1. <?php
    2. session_start();
    3. if (isset($_SESSION['myPass'])){
    4.  header("Location: index.php");
    5. }
    6. ?>
    7. <?php
    8. $myUsername="";
    9. $myPass="";
    10. //convert the POST variables from the html to local variables
    11. if (isset($_POST['myUsername'], $_POST['myPass'])){
    12. $Admin = mysql_real_escape_string($_POST['myUsername']);
    13. $Pass = mysql_real_escape_string($_POST['myPass']);
    14.  header("Location: admin.php");
    15. }else {
    16.     echo 'Something went wrong';
    17.  
    18. }
    19. ?>
    Last edited by Nightwalker83; Oct 31st, 2012 at 11:12 PM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2012
    Posts
    81

    Re: Convert to PHP5.3

    //convert the POST variables from the html to local variables
    what?

    and what's that $Admin = mysql_real_escape_string($_POST['myUsername']);
    I dont have mysql

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Convert to PHP5.3

    Don't worry about that comment I was using the conditional statement from an old project of mine! You can remove the comment. Oh, the "mysql_real_escape_string()" can be removed. What are you using instead?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Convert to PHP5.3

    $_POST is an associative array which contains the key-value pairs of the data you submitted via your HTML form.
    //convert the POST variables from the html to local variables
    I think he meant to say that he is assigning the values from the $_POST array to variables.

    mysql_real_escape_string() is a function that escapes special characters in a string , if you intended to store in database. In short, to prevent sql injection attacks. But that function is in the path of extinction. I mean, it is better to use PDO or mysqli than the mysql_* functions.

    @NightWalker: in your code, the second starting tag of the second PHP code portion is incorrect. You used "$" instead of "?". Most probably a typo.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Convert to PHP5.3

    Quote Originally Posted by akhileshbc View Post
    @NightWalker: in your code, the second starting tag of the second PHP code portion is incorrect. You used "$" instead of "?". Most probably a typo.
    Yes, that was a typo! Thanks for pointing it out. I have fixed the above code.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2012
    Posts
    81

    Re: Convert to PHP5.3

    Doesn't work. I don't use any databases..

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Convert to PHP5.3

    I have to say your request is a more than a little unusual. There is nothing in that code that explicitly ties it to a particular version of PHP, except for the use of session_register, which was deprecated (but still available) in 5.3 and removed in 5.4. Whether the code works or not is impossible for us to say based only on what appears to be two small snippets of what is presumably a larger system, so I don't understand what you wish for us to help you with.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width