Page 1 of 1
Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:46 pm
by ashwood
ive done this:
<input type='hidden' name='username' value='<?php echo $_SESSION['login_username']; ?>' />
and then my php
<?php
mysql_connect("*****************,"*****************","**********************");
mysql_select_db("*********);
$username = $_POST['username'];
$message = mysql_real_escape_string($_POST['lname']);
mysql_query("INSERT INTO shoutbox VALUES ('$username','$message')") or die("Problem");
?>
it goes into the database BUT the username in the database.. where in the column it should say ashwood as the username is says undefined but the message shows the message..
whats the problem? thanks
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:48 pm
by jacek
"undefined" is what javascript uses for undefined variables, are you submitting the form via AJAX ?
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:50 pm
by ashwood
yeah its todo with the topic i have in javascript section but thats complete now it works just this bit.. should i post the ajax?
edit:
$(document).ready(function(){
$("form#submit").submit(function() {
var username = $('#username').attr('value');
var lname = $('#lname').attr('value');
$.ajax({
type: "POST",
url: "sbox_data.php",
data: "username="+ username +"& lname="+ lname,
success: function() {
$('#lname').val('');
}
});
return false;
});
});
alls ive done is changed fname to username :S?
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:51 pm
by jacek
ashwood wrote:should i post the ajax?
Post the full code
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:52 pm
by ashwood
full code? all different docs dude what do u need?
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:52 pm
by jacek
Does your input have the id of "username" ?
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:53 pm
by ashwood
nope only name should ill add id and report back
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:54 pm
by jacek
Okay
data: "username="+ username +"& lname="+ lname,
also should this be
data: "username="+ username +"&lname="+ lname,
with no space.
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:54 pm
by ashwood
well what do you no them 2 little letters made a differnece sorted
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:55 pm
by jacek
ashwood wrote:well what do you no them 2 little letters made a differnece sorted
good news
And moved to javascript
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 3:56 pm
by ashwood
how would i add say displayname onto the data?
Re: Hidden TextBox Value
Posted: Sun Jun 19, 2011 4:00 pm
by ashwood
DONE IT