Forum Moderators: coopster

Message Too Old, No Replies

PHP form does NOTHING

Help Please

         

djtwo

6:32 pm on Jul 27, 2006 (gmt 0)

10+ Year Member



Hi I made a simple script and form that saves email addresses in a database. When i combine just the html form and PHP script in one file (without the html template of my website), I get know errors and the form works perfect every time.

However I attempted to add the form w/script in with my html Template (which is in html and the file ends with ".php", which, I have tried that in other projects and it worked fine). I placed the PHP Script above everything else and I placed the actual Form in the middle of the Template where I want it to display.

Ok, now what happens is:

1.) I get know error messages (good), BUT
2.) When I submit the form NOTHING happens other
than going to the same page using

"<form action="signup1234.php?do=new" method="post">" where "signup1234.php" is the url of the page I originally was at.

I AM SUPPOSE TO GET A MESSAGE BACK (above the form) STATING THAT THE EMAIL WAS SENT (meaning it was successfully added to the database).

However I can tell that nothing happed within the database, nor was there any actual connection with the database.

I have the code if anyone wants to take a look at it. I can't think of any specific piece of code to paste here.

Any suggestions. Thanks ahead of time for all your help and support.

Regards,

djtwo

jatar_k

9:22 pm on Jul 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



my wild guess is that your sql isn't working. You could try adding a statement after your mysql query call, it would be something like

$q = "select * from mytablename";
$query = mysql_query($q) or die(mysql_error());

if there is an error from mysql that will return it to you

djtwo

12:53 am on Jul 28, 2006 (gmt 0)

10+ Year Member



Thanks for the help Jatar. However that wasn't the problem....Silly me, I forgot my first steps to programming.

It turns out the the code was good in ALL, BUT since I placed the PHP script at top, I forgot how it reponded with the HTML tags and so forth (ex. headers).

My solution was rather easy, although I spent almost 8 hours total trying to figure it all out.

The solution: Simply have seperate files. My Php script was seperate from the Web Template which contained the form. In my PHP script I "included" during each "if" or "else" the page which contained the template and form.

For example:

if (isset($_GET['do']))
$message_new = " <font color='#FF0000'>$referemail already used.</font>";
include('signup1_form.php');
exit();
}

While the page I was on ( ...signup1.php) was my Script which included the above code.

I hope that makes sense. Now it is all making more and more sense to me. Thanks everyone for all your help. Jatar, keep up the excellent work. Ya'll have a good day and great weekend.

Best Regards,

Djtwo