Hack Forums
enter your name on a website - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: enter your name on a website (/showthread.php?tid=2490521)



enter your name on a website - SIM-1179501 - May 12, 2012

On my site I wanted to make it so before a user entered the page it there would be a pop up asking for their name, after that somewhere in the page I could type something and it would say in the page what they typed in.
for example
Code
1) Enter your name here: <name>
2) welcome to my site <name>
I've seen this done before But I don't remember the site so I cant get the source. Does anyone know the html code for this?


* - Webmasters - May 12, 2012

What are you wanting their name to do?

Just entering it is pointless..

What you want it to do once entered?


* - raxe - May 12, 2012

Might be for a username script.
Just use PHP sessions to store their name..

Pop up name > store name > stay in session > log out

Isn't hard for a script, good luck!


* - SIM-1179501 - May 13, 2012

I would want it to appear in the text somewhere


* - dotcomdog - Apr 9, 2013

Just dont do it then ok got it noob?


* - Duncanrp - Apr 9, 2013

You could just use a session variable so e.g.

PHP Code

<?php 
$_SESSION
['name'] = your input... 

Then whenever you want to refer to it you just go like so.

PHP Code

<?php 
Welcome
, <b><?php echo $_SESSION['name']; ?></b> 



* - Kawop - Apr 9, 2013

(Apr 9, 2013 07:30 PM)Duncanrp Wrote:  You could just use a session variable so e.g.

PHP Code

<?php 
$_SESSION
['name'] = your input... 

Then whenever you want to refer to it you just go like so.

PHP Code

<?php 
Welcome
, <b><?php echo $_SESSION['name']; ?></b> 

Don't forgot to type
PHP Code

<?php 
session_start 
in the strictly top of you *.php 🤫


* - [Johny] - Apr 9, 2013

Or you can do it like this:
PHP Code

<?php
$_POST
['name'];
if(isset(
$_POST['submit']))
{
$name=$_POST['name'];
echo(
$name);
}
?>



* - Hack3rzGod - Apr 10, 2013

If you want this on a single page use
JScript::

Head Area

Code
<script>
var name=prompt("What Is Your Name?","Your Name");
</script>

Body Area
Code
<script>
document.writeln("Welcome " + name);
</script>

else use PHP + Javascript
save the name in a session using post or get method and use on multiple page.