|
-
Jul 29th, 2002, 01:14 AM
#1
Thread Starter
Lively Member
Submit Form
hey all,
sorry for the newb question but my host has global_variables OFF and for the life of me i cannot get a form to submit 
PHP Code:
<?
if(isset($_POST['submit'])):
$info = isset($_REQUEST['info']) ? $_REQUEST['info'] : '';
$sql = "UPDATE tourney_admin SET tourney_info='" . addslashes($info) . "'";
$result = mysql_query($sql)
or die("Update failed.\n");
echo "Tournament info has been added/updated.\n";
else:
?>
<center><b>View/Edit Tourney Info</b>
<form method="post" action="index.php?action=info">
<textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'] ?>"></textarea><br>
<input type="image" src="/images/buttons/submit.gif" value="Submit!" alt="Submit!" name="submit">
</form>
</center>
<?
endif;
?>
can anyone see anything wrong with that and tell me why it wont submit??
when i click the submit button, all it does is refresh the page, but nothing goes to the database.
thanks for the help
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Jul 29th, 2002, 01:54 AM
#2
Fanatic Member
1| what the hell are you trying to do here:
PHP Code:
$info = isset($_REQUEST['info']) ? $_REQUEST['info'] : '';
???
and u could have asked me for help today at school in the comp room, i was bored out of my brain !!! 
2| I like the way you style ur ELSE ENDIF thing's 
my solution: give me a definition of exactly what you want to do and i'll we write that code for you.
-
Jul 29th, 2002, 05:56 PM
#3
Thread Starter
Lively Member
lol, i have no idea what that is, im using it because i get no errors about undefined index and with $info = $_REQUEST['info'] i get errors 
and all im trying to do is get what the user types in the textarea named info to go into my database 
i have never been able to get a form to work and its REALLY pissing me off
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Jul 29th, 2002, 06:50 PM
#4
Addicted Member
FYI:
PHP Code:
$info = isset($_REQUEST['info']) ? $_REQUEST['info'] : '';
That is similar to the vb IIF. If the first part is true, then it returns the second part , else it returns the third part.
It is just checking if $_REQUEST['info'] is set and return it if it is (wow...4 two letter words beginning in 'i'!).
-
Jul 29th, 2002, 08:26 PM
#5
Fanatic Member
you need a "where" clause in your UPDATE sql statement for 1, unless you want all the records to contain the same info.
Secondly, you should add .mysql_error() to your die() function as it will give you a more detailed error message.
Thirdly, check to see if you are connected to the database.
-Matt
-
Jul 30th, 2002, 12:01 AM
#6
Thread Starter
Lively Member
ok, so the updated code is this
PHP Code:
<?
if(isset($_POST['submit'])):
$info = isset($_REQUEST['info']) ? $_REQUEST['info'] : '';
$sql = "UPDATE tourney_admin SET tourney_info='" . addslashes($info) . "'WHERE id=1";
$result = mysql_query($sql)
or die("Update failed.\n");
echo "Tournament info has been added/updated.\n";
else:
?>
<center><b>View/Edit Tourney Info</b>
<form method="post" action="index.php?action=info">
<textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'] ?>"></textarea><br>
<input type="image" src="/images/buttons/submit.gif" value="Submit!" alt="Submit!" name="submit">
</form>
</center>
<?
endif;
?>
but i dont have any problems with the database, my problem is the form wont "submit". it just keeps refreshing the page when i click Submit and doesnt acknowledge that the user has entered the information in the form.
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Jul 30th, 2002, 04:33 AM
#7
Fanatic Member
well, i cant figure out EXACTLY what you want, but i menaged to convert the following code:
PHP Code:
<?
if(isset($_POST['submit']))
{
$submit = $_POST['submit'];
$sql = "UPDATE tourney_admin SET tourney_info='" . .addslashes($info) . "'WHERE id=1";
$result = mysql_query($sql) or die("Submit Query Failed");
ECHO "Tournament info has been added/updated.\n";
} ELSE {
?>
<center><b>View/Edit Tourney Info</b>
<form method="post" action="index.php?action=info">
<textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'] ?>"></textarea><br>
<input type="submit" value="Submit!">
</form>
</center>
<?
}
unset($submit);
?>
-
Jul 30th, 2002, 05:49 AM
#8
Fanatic Member
I notice you have the action for your form set to : index.php?action=info
I did this once and it caused problems for me, what you should do is make a hidden field to store that value like so:
<input type="hidden" name="action" value="info" />
And you need a space between ' and where
-
Jul 30th, 2002, 06:34 AM
#9
Thread Starter
Lively Member
still nothing, and cpradio, im not exactly sure what your talking about
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Jul 30th, 2002, 06:48 AM
#10
Fanatic Member
you have this (red area is where I have had a problem in the past):
<form method="post" action="index.php?action=info">
I would change that to:
<form method="post" action="index.php">
<input type="hidden" name="action" value="info" />
-Matt
-
Jul 30th, 2002, 09:39 AM
#11
Frenzied Member
why have action=info if all you are doing is checking for submit? if you want action then do it like this
PHP Code:
<?
switch ($_POST["action"]){
case "info":
$info = isset($_POST['info']) ? $_POST['info'] : '';
$sql = "UPDATE tourney_admin SET tourney_info='" . addslashes($info) . "'WHERE id=1";
$result = mysql_query($sql)
or die("Update failed.\n");
echo "Tournament info has been added/updated.\n";
break;
default:
?>
<center><b>View/Edit Tourney Info</b>
<form method="post" action="index.php?action=info">
<textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'] ?>"></textarea><br>
<input type="image" src="/images/buttons/submit.gif" value="Submit!" alt="Submit!" name="submit">
</form>
</center>
<?
}
?>
if you you are not using action then just take it off.
-
Aug 11th, 2002, 01:00 PM
#12
Member
is therea way you can do that straight to your e-mail address?
 Platty rules 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|