Jump to content


form submission not working


4 replies to this topic

#1 Suspicion

    Young Padawan

  • Members
  • Pip
  • 30 posts
  • Location:Littleton, CO, USA

Posted 02 May 2006 - 06:25 PM

OK so I have a form I'm trying to code and I want to use an <a></a> submit link but it's not working.

I currently have it set up to when I click the "Next Step »" link it should submit the form and echo "yay". But it's not doing this...

Here is my code so far for this section of my site:

<?PHP
	if ($_POST['next']) {
		echo("yay");
	} else {
?>
<tr>
	<td align="center" valign="top">
		<table cellpadding="0" cellspacing="0" align="center" class="header">
			<tr>
				<td align="left" valign="top" width="10">
					<img src="../images/content-header-left.gif" border="0" alt="" /></td>
				<td align="left" valign="middle">
					<span class="generalTextBold">Suspicion Studios Database Installer</span></td>
				<td align="right" valign="middle">
					<span class="generalTextBold">Step <span class="header-green">1</span> of <span class="header-green">2</span></span></td>
				<td align="right" valign="top" width="10">
					<img src="../images/content-header-right.gif" border="0" alt="" /></td>
			</tr>
		</table>
	</td>
</tr>
<tr>
	<td align="center" valign="top">
		<table cellpadding="0" cellspacing="0" align="center" class="content">
			<form name="form" method="post">
			<tr>
				<td align="center" valign="top" colspan="2">
					<span class="generalTextBold">Welcome to your database installation.<br />
					All fields in this installation are required for proper installation.</span></td>
			</tr>
			<tr>
				<td align="right" valign="middle" style="width:40%">
					<span class="generalTextBold">Site Name:&nbsp;</span></td>
				<td align="left" valign="top" style="width:60%;">
					<input type="text" name="sitename" /></td>
			</tr>
			<tr>
				<td align="right" valign="middle" style="width:40%">
					<span class="generalTextBold">Site Description:&nbsp;</span></td>
				<td align="left" valign="top" style="width:60%;">
					<input type="text" name="sitename" /></td>
			</tr>
			<tr>
				<td align="right" valign="top" style="padding-top:5px;" colspan="2">
					<a href="java script:document.form.submit()" name="next">Next Step »</a></td>
			</tr>
			</form>
		</table>
	</td>
</tr>
<tr>
	<td align="center" valign="top">
		<table cellpadding="0" cellspacing="0" align="center" class="footer">
			<tr>
				<td align="left" valign="top">
					<img src="./images/content-footer-left.gif" border="0" alt="" /></td>
				<td align="right" valign="top">
					<img src="./images/content-footer-right.gif" border="0" alt="" /></td>
			</tr>
		</table>
	</td>
</tr>
<?PHP
	}
?>

I have tried and tried on this issue as I have wanted to get this working for other sites. This time I'm not going to give up, I really need this to work... Does anyone know why it wont catch the submit and then echo "yay"?

#2 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 02 May 2006 - 08:16 PM

simple. there is no variable named $_POST['next'];

what you have to do is add an action to the form, and make the action some other page.

#3 Suspicion

    Young Padawan

  • Members
  • Pip
  • 30 posts
  • Location:Littleton, CO, USA

Posted 02 May 2006 - 10:07 PM

So just make another page that has all the stuff needed in it. And the form will read that and then post what I need done?

If I'm understanding this right, I think I know what to do then. I'll work with it in the morning and get back to you :)

Edited by Suspicion, 02 May 2006 - 10:07 PM.


#4 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 02 May 2006 - 10:58 PM

yep, using your example, you'd have another page like action.php and have this code in there

if ($_POST['next']) {
		echo("yay");
	}

excpet, next doesn't exist, so you better use something like this to make sure fields were set:

if(isset($_POST['inputfield']) && isset($_POST['inputfield2']))
{
   echo "Info was set<br /> \n";
}
else
{
   echo "Error...<br /> \n";
}


#5 syphon

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 04 May 2006 - 08:16 PM

Also,
				<td align="right" valign="top" style="padding-top:5px;" colspan="2">
					<a href="java script:document.form.submit()" name="next">Next Step »</a></td>
			</tr>

You have a space between "java" and "script", oh and you can have the action of a form to be the same page, it would work the way you had it
	if ($_POST['next']) {
		echo("yay");
	} else {
		 // Whatever error
	}
assuming you have an input or textarea named "next"

du





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users