Basic PHP Script [closed]
I'm trying to make a script to do the following:
http://mydomain.com/script.php?name=bob
That link would output to a blank page with text
Hi bob
Anyone know what the contents of script.php sh开发者_如何学Goould be?
<?php echo 'Hi ', htmlspecialchars($_GET['name'], ENT_QUOTES), ' and welcome'; ?>
or simply
<?php echo 'Hi '. $_GET['name'] .' and welcome'; ?>
You should learn PHP from a book or tutorials. This is not the way to learn it.
<?php
echo 'Hi '. $_GET['name'];
?>
Making sure of course to sanitize your variables before you use them for anything.
if the text that is name = bob
coming from db. then you can $_GET the name and concatenate that here.
for button or submit
onclick="location.href='script.php?name=<?php echo $name ?>'"
for text link
<a href="script.php?id=<?php echo $name;?>">view</a>
write this in script.php
<? php echo 'HI'.$_GET['name']; ?>
精彩评论