get use $_GET['username'] in my form
Posted: Wed May 14, 2008 3:50 pm
ok above if($_POST['submit']) i can grab the name via $_GET['username'] but anything below then i cannot echo it...how comes??
PHP Code:
get username gets the name of the profile form the url due to this
is it because i need to do somethingwith action="box.php" .... this page is actually box.php itself so allits really doing is sending it back to this page....
the page i have included this script on has the name in the url... if i went to just mywebsite.com/box.php it would look like that so i included it on http://www.mywebsite.com/username i thought i best tell you all this as it might be very improtant lol
PHP Code:
get username gets the name of the profile form the url due to this
Code: Select all
RewriteRule ^([^/.]+)/?$ members/index.php?page=profile&username=$1Code: Select all
<?php session_start();
?>
<style type="text/css">
<!--
.message {
color: #000000;
font-family: Verdana;
font-size: 10px;}
.username {
color: #FF9900
font-family: Verdana;
font-size: 4px;
font-weight: bold}
.date {
color: #707070;
font-family: Verdana;
font-size: 2px;}
.forms {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10 px;
color: #6CA05A;
text-decoration: none;
background-color: #CCCCCC;
border-color: #6CA05A;
border-style: solid;
border: 1px}
.submit {
background-color: #CCCCCC;
border-color: #6CA05A;
color: #2A343C;
font-family: Verdana;
font-size: 10px;
border-style: solid;
border 1 px;}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="padding: 2px">
<?php
$user = isset($_GET['username'])? $_GET['username'] : "";
//echo $user; this displays the user name but anything below it does not
if($_POST['submit']) {
// Verify if the fields were filled.
if(!$_POST['message']) {
echo 'Error, You need to post a Message!';
die;
}
// Date format
$date = date("d/m/y"); // http://www.php.net/date
// Assign variables of the forms
// Connect to the database
include('../settings.php');
$user1 = $_POST['usersaccount'];
$id = $_SESSION['user_id'];
$username = get_username($id);
$message = $_POST['message'];
$ip = $_SERVER['REMOTE_ADDR'];
// Insert the info in the shoutbox table.
$query = "INSERT INTO shoutbox (`user`, username, message, date, ip)
VALUES ('$user1','$username','$message','$date','$ip')";
mysql_query($query);
// close connection
// Show message to let them return to the shoutbox
?>
<div align="center">Thank you for submitting.<br>
Return to the <a href="shoutbox.php">shoutbox</a>!
<?php
// If NOT submitted
} else {
$query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 3";
$result = mysql_query($query);
// Create a table
?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<?
// Run a While loop for the rows
while($c = mysql_fetch_array($result))
{
?>
<tr>
<td>
<? echo $c[username] ?> says:
<div align="justify"><? echo $c[message] ?></div>
</td>
</tr>
<tr><td>on <? echo $c[date] ?>
<hr noshade="noshade" size="1" style="border-style: dashed" color="#000000" /></td></tr>
<? } ?>
</table>
<form method="post" action="box.php">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Message :</td>
<td><input type="text" name="message" class="forms"><input type="hidden" id="usersaccount" name="usersaccount" value="<?php $user ;?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Speak!" class="subtmit"></td>
</tr>
</table>
</form>
<?php } ?>
</body>
</html> the page i have included this script on has the name in the url... if i went to just mywebsite.com/box.php it would look like that so i included it on http://www.mywebsite.com/username i thought i best tell you all this as it might be very improtant lol