|
-
Oct 30th, 2012, 02:18 PM
#1
Thread Starter
Lively Member
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.
-
Oct 31st, 2012, 03:26 AM
#2
Re: Convert to PHP5.3
This is untested but should work.
php Code:
<?php
session_start();
if (isset($_SESSION['myPass'])){
header("Location: index.php");
}
?>
<?php
$myUsername="";
$myPass="";
//convert the POST variables from the html to local variables
if (isset($_POST['myUsername'], $_POST['myPass'])){
$Admin = mysql_real_escape_string($_POST['myUsername']);
$Pass = mysql_real_escape_string($_POST['myPass']);
header("Location: admin.php");
}else {
echo 'Something went wrong';
}
?>
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
-
Oct 31st, 2012, 11:26 AM
#3
Thread Starter
Lively Member
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
-
Oct 31st, 2012, 04:54 PM
#4
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
-
Oct 31st, 2012, 10:32 PM
#5
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,...
-
Oct 31st, 2012, 11:10 PM
#6
Re: Convert to PHP5.3
 Originally Posted by akhileshbc
@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
-
Nov 1st, 2012, 02:16 PM
#7
Thread Starter
Lively Member
Re: Convert to PHP5.3
Doesn't work. I don't use any databases..
-
Nov 1st, 2012, 09:11 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|