Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,480 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,724 people online right now. Registration is fast and FREE... Join Now!




form submission not doing anything

 
Reply to this topicStart new topic

form submission not doing anything

capty99
24 Feb, 2008 - 08:05 PM
Post #1

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,164



Thanked: 16 times
Dream Kudos: 550
My Contributions
alright, don't think i'm not working on these problems on my own, this one i've just had since last night and can't see the problem.

I have this form simple addition to the db, as simple as I can make it and I will add on to it later as soon as I can get it working...

Anyways, whenever I click submit I don't get the error display or the confirmation. It resets the form and nothing else happens.

Any tips? thanks.

php

<html>
<body>
<?
// form not yet submitted
// display initial form
if (!$submit)
{
?>
<form action="<? echo $PHP_SELF; ?>" method="POST">
<input size="50" maxlength="250" type="text" name="cname">
<textarea name="coverview" cols="40" rows="10"></textarea>
<input type="Submit" name="submit" value="Submit">
</form>
<?
}
else
{
// includes
include("../conf.php");

// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// generate and execute query
$query = "INSERT INTO shopcenter(cname, coverview) VALUES('$cname', '$coverview')";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

// print result
echo "<font size=-1>Update successful. <a href=list.php>Go back to the main menu</a>.</font>";

// close database connection
mysql_close($connection);
}
?>
</body>
</html>

User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Form Submission Not Doing Anything
24 Feb, 2008 - 08:15 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,465



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE

php

<form action="<? echo $PHP_SELF; ?>" method="POST">

Are you sure that $PHP_SELF is using the correct value? Try typing the page in there, just to test.
Also, when in doubt, try changing POST to get, just so you can visually verify that the values are in fact being pushed over.
User is online!Profile CardPM
+Quote Post

capty99
RE: Form Submission Not Doing Anything
24 Feb, 2008 - 08:45 PM
Post #3

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,164



Thanked: 16 times
Dream Kudos: 550
My Contributions
i tried both, and it didn't run. a found someone else's code and am using that now... only thing different is it declares the variables seperate♠

$cname = $_POST['name'];
$csubhead = $_POST['subhead'];

thanks for looking though man

User is offlineProfile CardPM
+Quote Post

canty
RE: Form Submission Not Doing Anything
25 Feb, 2008 - 01:56 AM
Post #4

New D.I.C Head
*

Joined: 26 Jan, 2008
Posts: 12


My Contributions
QUOTE(capty99 @ 24 Feb, 2008 - 09:45 PM) *

i tried both, and it didn't run. a found someone else's code and am using that now... only thing different is it declares the variables seperate♠

$cname = $_POST['name'];
$csubhead = $_POST['subhead'];

thanks for looking though man


i see in your code that the name is cname not name so you may be try
$cname = $HTTP_POST_VARS["cname"];
$coverview = $HTTP_POST_VARS["coverview"];

and echo $cname.$coverview ..

use $HTTP_POST_VARS["submit"] in if condition, or change register_globals = on in your php.ini

this is the complete code
CODE


<?php
if ($HTTP_POST_VARS["submit"])
{
$cname = $HTTP_POST_VARS["cname"];
$coverview = $HTTP_POST_VARS["coverview"];
echo "cname = ".$cname." and coverview = ". $coverview;
}

else
{
?>
<html>
<head>
<title>
what ever
</title>
</head>
<body>
<form action="<?php echo $PHP_SELF;?>" method="POST">  
<input size="50" maxlength="250" type="text" name="cname">  
<textarea name="coverview" cols="40" rows="10"></textarea>  
<input type="Submit" name="submit" value="Submit">  
</form>  
</body>

</html>
<?php }?>



I hope this code can help you !!!

and please visit my blog biggrin.gif
<a href="http://canty.web.id">[-canty 4 ever-]</a>
User is offlineProfile CardPM
+Quote Post

ahmad_511
RE: Form Submission Not Doing Anything
25 Feb, 2008 - 03:54 AM
Post #5

D.I.C Regular
Group Icon

Joined: 28 Apr, 2007
Posts: 351



Thanked: 8 times
Dream Kudos: 400
My Contributions
Hello
I just noticed that depending on php.net document it must be $_SERVER['PHP_SELF'] not $PHP_SELF
So I'm not sure

Regards
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: Form Submission Not Doing Anything
25 Feb, 2008 - 07:27 AM
Post #6

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

as they are saying..
is beter to code with register globals off.
and you are using old server settings.

form action is only needed it is being posted to a different page.

try,
CODE

<html>  
<body>  
<?  
// form not yet submitted  
// display initial form  
if (!$_POST['submit'])  
{  
?>  
<form method="POST">  
<input size="50" maxlength="250" type="text" name="cname">  
<textarea name="coverview" cols="40" rows="10"></textarea>  
<input type="Submit" name="submit" value="Submit">  
</form>  
<?  
}  
else  
{  
    // includes  
    include("../conf.php");  
  
        // open database connection  
        $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");  
  
        // select database  
        mysql_select_db($db) or die ("Unable to select database!");  
  
        // generate and execute query  
        $query = 'INSERT INTO shopcenter(cname, coverview) VALUES("'.mysql_real_escape_string(stripslashes($_POST['cname'])).'", "'.mysql_real_escape_string(stripslashes($_POST['coverview'])).'")';  
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());  
  
        // print result  
        echo "<font size=-1>Update successful. <a href=list.php>Go back to the main menu</a>.</font>";  
  
        // close database connection  
        mysql_close($connection);  
    }  
?>  
</body>  
</html>  


User is offlineProfile CardPM
+Quote Post

canty
RE: Form Submission Not Doing Anything
25 Feb, 2008 - 10:56 PM
Post #7

New D.I.C Head
*

Joined: 26 Jan, 2008
Posts: 12


My Contributions
QUOTE(ahmad_511 @ 25 Feb, 2008 - 04:54 AM) *

Hello
I just noticed that depending on php.net document it must be $_SERVER['PHP_SELF'] not $PHP_SELF
So I'm not sure

Regards


I'm use XAMPP 1.6.5, it use PHP Version 5.2.5 !!!
and i have success to post a variable from the HTML use $PHP_SELF

and the wrong from the first post is
if ($submit)

maybe the register_global = off , so the php can't catch the variable from form !!!
$submit <--- is return null not true and not false !!!

if use $HTTP_POST_VARS["submit"] <--- this will be return true !!!

Thanks !!!

biggrin.gif
User is offlineProfile CardPM
+Quote Post

ahmad_511
RE: Form Submission Not Doing Anything
26 Feb, 2008 - 12:10 PM
Post #8

D.I.C Regular
Group Icon

Joined: 28 Apr, 2007
Posts: 351



Thanked: 8 times
Dream Kudos: 400
My Contributions
Thanks to you canty
I didn't notice that

Regards
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:56PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month