- Joined
- Apr 12, 2007
- Messages
- 426
- Reaction score
- 251
Hi guys!
I was bored so i started to work on a website, using PHP/JQuery-Ajax.
I dont know yet where or how the site will be used but right now im just working on it for fun and to learn :
Okay the questions now:
1. Having HTML codes inside a PHP function affects in any way the website?
Heres what i mean:
Then i have a switch:
Is there another/better way doing this?
2. Navigation using JQuery
I have one .js file to handle navigation in this way.
Any other/better way doing this?
3. I found an encryption/decryption function that uses a key to encrypt/decrypt strings and i thought i could use it for username/password/whatever encryption.
What do you think about it?
I still have a few more questions but this is enough for now :blush:
Thanks in advance!
I was bored so i started to work on a website, using PHP/JQuery-Ajax.
I dont know yet where or how the site will be used but right now im just working on it for fun and to learn :
Okay the questions now:
1. Having HTML codes inside a PHP function affects in any way the website?
Heres what i mean:
PHP:
function registerForm() {
echo "<form method='post' id='register_form'>";
echo "<input type='text' required='required' name='username' placeholder='Username'>";
echo "<input type='password' required='required' name='password' placeholder='Password'>";
echo "<input type='email' required='required' name='email' placeholder='E-Mail'>";
echo "<input type='submit' value='Submit'>";
echo "</form>";
echo "<div id='register_result'></div>";
}
Then i have a switch:
PHP:
switch ($_GET['action']) {
case "home":
frontpage();
break;
case "register":
registerForm();
break;
default:
frontpage();
}
Is there another/better way doing this?
2. Navigation using JQuery
PHP:
$("#register_menu").click(function(){
$.get("modules/main.php?action=register", function(result){
$("#main_content").hide().html(result).fadeIn("slow");
$("#register_form").submit(function(event){
$.post("modules/register.php", $(this).serialize(), function(data){
$("#register_result").hide().html(data).fadeIn("slow");
});
return false;
});
});
});
Any other/better way doing this?
3. I found an encryption/decryption function that uses a key to encrypt/decrypt strings and i thought i could use it for username/password/whatever encryption.
What do you think about it?
PHP:
function encrypt($magickey,$string) {
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($magickey), $string, MCRYPT_MODE_CBC, md5(md5($magickey))));
return $encrypted;
}
function decrypt($magickey,$encrypted) {
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($magickey), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($magickey))), "\0");
return $decrypted;
}
Thanks in advance!