Ok, you need to use a session. Place session_start() at the top of the file and use:
<?php
session_start();
if($_POST){
$_SESSION['q'] = $_POST['q'];
$q = $_SESSION['q'];
}
?>
<input type="text" name="q" VALUE="Slogan Maker" size="35" maxlength="255" style="height:38px;font-size:18px;" value="<?php echo $q;?>" />
<input type="submit" name="submit" value="Make Slogan!">
Do you need to take off the onfocus attibute?
You could unset the $_SESSION['q'] after the $q= ... line if you don't want the text to be propogated beyond the post action, e.g. page refresh.
diafol
Keep Smiling
10,647 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,509
Skill Endorsements: 57
Should go to the same page - sorry forgot the form tags! Doh!
<form method="post">
<input type="text" name="q" VALUE="Slogan Maker" size="35" maxlength="255" style="height:38px;font-size:18px;" onFocus="this.value=''"/>
<input type="submit" name="submit" value="Make Slogan!">
</form>
diafol
Keep Smiling
10,647 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,509
Skill Endorsements: 57
Oh gawd, doh! Here you go, hope I've got it right this time:
<?php
session_start();
if($_POST){
$_SESSION['q'] = $_POST['q'];
$q = $_SESSION['q'];
}
?>
<form method="post">
<input type="text" name="q" VALUE="Slogan Maker" size="35" maxlength="255" style="height:38px;font-size:18px;" value="<?php echo $q;?> />
<input type="submit" name="submit" value="Make Slogan!">
</form>
Just a note, if you send the form to itself (same page) a refresh following a form submit will resend the data. As a rule forms are sent to different pages/files for processing and then redirected back to the form if req'd. The session solution works equally well for this, although you need to spread the code over two pages/files.
diafol
Keep Smiling
10,647 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,509
Skill Endorsements: 57