Jump to content

need help with small php PLEASE...


Alidad

Recommended Posts

Please copy this code and run on your editor and see preview, as you can see when you type user name and it will show text type writer after press enter, these code is under javascripts.

 

Now i want to change to session variable in php code, if person log in by type the user name in log.php and redirect to home page index.php to show "Welcome [user_name]", how is that possible to write code in php to show text type writer in session variable in home page after they log in log.php page!

 

please help!

 

see code in bottom:

 

<html> 
<head> 
<title>Decrypting Text Effect</title> 
<style> 
a:visited{color:black;font-family:verdana} 
a:link{color:black;font-family:verdana} 
a:hover{color:blue;font-family:verdana} 

td {color:black;font-family:verdana;font size:8pt} 
p {color:black;font-family:verdana;font size:8pt;text-decoration: none} 
h1 {color:black;font-family:verdana;font size:12pt;text-decoration: none} 
</style> 

<script language="javascript"> 
var got; 
var chars; 
function change() 
{ 
var randstring = ""; 
var rslength = chars.length - got.length; 

var decrypted = document.getElementById("decoded"); 
var encrypted = document.getElementById("encoded"); 

for(var x=0;x<rslength;x++) 
{ 
i = Math.floor(Math.random() * chars.length); 
randstring += chars.charAt(i); 
} 

if(randstring.charAt(0) == chars.charAt(got.length)) 
{ 
got += randstring.charAt(0); 
decrypted.innerHTML = got; 
} 
else 
{ 
encrypted.innerHTML = randstring; 
} 

if(chars.length > got.length) 
{ 
setTimeout("change()", 10); 
} 
else 
{ 
encrypted.innerHTML = ""; 
} 
} 
function startdecrypt() 
{ 
var decrypted = document.getElementById("decoded"); 
var encrypted = document.getElementById("encoded"); 
decrypted.innerHTML = document.getElementById("firstN").value; 
chars = decrypted.innerHTML; 
decrypted.innerHTML = ""; 
got = ""; 
setTimeout("change()", 10); 
} 
</script> 
</head> 
<body> 
Enter your name here: <input type="text" id="firstN"> 
<input type="button" onClick="startdecrypt()" value="Start"> 
<p> 
<span id="decoded">Your text goes here.</span><span id="encoded"></span> 
</p> 
</body> 
</html>

 

(edited to add


tags)

Link to comment
https://forums.phpfreaks.com/topic/44585-need-help-with-small-php-please/
Share on other sites

<?php

 

session_start();

if(isset($_POST)){

if(isset($_POST['firstN'])){

session_register('username');

$_SESSION['username'] = $_POST['firstN'];

echo "The value set in session is ".$_SESSION['username'];

}

}

?>

<html>

<head>

<title>Decrypting Text Effect</title>

<style>

a:visited{color:black;font-family:verdana}

a:link{color:black;font-family:verdana}

a:hover{color:blue;font-family:verdana}

 

td {color:black;font-family:verdana;font size:8pt}

p {color:black;font-family:verdana;font size:8pt;text-decoration: none}

h1 {color:black;font-family:verdana;font size:12pt;text-decoration: none}

</style>

<script language="javascript">

function check(){

if(document.frm.firstN.value == ''){

alert('Please enter name');

return false;

}

}

</script>

 

</head>

<body>

<form name="frm" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" onsubmit="return check();">

Enter your name here: <input type="text" id="firstN" name="firstN">

<input type="submit" name="submit" value="Start">

</form>

</body>

</html>

 

-----------------------------------------------

Now at each page you want to user session variable 'username' write

file : index.php

<?php

session_start();

echo "welcome ".$_SESSION['username'];

?>

thanks so much for your help, but is not working for me, i have tested  your code and i undersand this code and I have tried to make change to make work but still not working.

 

Is that possible that you can help me again, can you possible to put combine togther in php and javascripts to show animation text with session variable please!

 

AM

It would be very simple to do what you want. Here is what you should do:

 

<?php
   session_start();
   if(isset($_POST)){
      if(isset($_POST['firstN'])){
         session_register('username');
         $_SESSION['username'] = $_POST['firstN'];
         echo "The value set in session is ".$_SESSION['username'];<--insert javascript here and escape " with \"
      }
   }

?>

yes i total understand this but the problme i have is that is not carry the text type write,  i like to have with text type writer  with user name, i could not figure out why is not carry to other page with text type writer !

 

does any one know what went wrong with that code!

 

AM

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.