954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Form wont work properly when echoed

Hi,

I am kind of new to PHP, learning through books and online resources but I am having difficulties with what seems like an easy problem.

if($pageid == 1){
		echo "";	
		} else {
		echo '<form action="delete_ad.php" method="post">';
		echo '<input name="deleteid" type="text" value="" id="deleteid"  hspace="10"/>';
		echo '<input name="delete" type="submit" value="Delete Ad" id="deletebtn"/>';
		echo '';
		echo '<table id="emailform" class="signup">
		<th colspan="2" align="center">Email Form</th>
		<form method="post" action="send.php">
		<tr><td>Name</td><td><input type="text" maxlength="32"
		name="name" /></td>
		</tr><tr><td>Email</td><td><input type="text" maxlength="32"
		name="senderemail" /></td>
		</tr><tr><td>Message</td><td><textarea name="message"></textarea></td>
		</tr><tr><td colspan="2" align="center">
		<input type="submit" value="Send" /></td>
		</tr></form></table>';
		}


The green part works, while the form in the red part does not want to work, when ever I click on Send it brings me back to the homepage instead of going to send.php. I know its better to use html and then send it to php, and when I do that everything works fine, but in this particular case I need it to be echoed. I tried to put the html in a mysql table and echo it, but that did not work. I tried to use =\"...\" syntax, but it also did not work. I don't know what else to do.

Thanks for the help

zyzagy
Newbie Poster
1 post since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

you forgot to close form tag for this

echo '';

close it before

it will work.

shubforall
Newbie Poster
5 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

One form can not contain another form.

mahavir123
Junior Poster in Training
95 posts since Sep 2010
Reputation Points: 11
Solved Threads: 35
 

hi,
you need to close the first form tag !

monica singh
Light Poster
48 posts since Oct 2010
Reputation Points: 11
Solved Threads: 10
 

What everyone else has said plus you need the first line of your table in a row. You've got the <th> but it's not within a <tr> and since it's the only one in the row, you need to use colspan="2" too.

Borzoi
Posting Whiz
324 posts since Oct 2006
Reputation Points: 21
Solved Threads: 30
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: