Page 1 of 1

PHP Form fiasco

Posted: Sun Dec 05, 2010 12:48 pm
by cap2cap10
Greetings again, PHP technorati. I hope you all had a great Thanksgiving. OK, I come to you with another of my perplexing php form glitches. I am creating a content management system where I have to input small bits of information to a database. I have 5 form scripts on one page. When I try to submit info from my second form, the php page reads the Form action of the **first** form! :banghead: All form actions lead to external php scripts that will perform the functions and redirect back to the original php form page. Here is some code:

Code: Select all

<?php
$email = $row1['e-mail'];
if ($row1['pitch'] == 'Yes') {
 echo "1-E-mail invite has been sent to Mark on ".$row1['date']."!";
 }
 elseif ($row1['pitch'] == 'No'){
 $text4 .= '<form method=POST action=enter1.php />';
 $text4 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12 />Job Title: <BR>';
 $text4 .= '<input name=state type=job_title  size=25 ><BR>';
 $text4 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12>State: <BR>';
 $text4 .= '<input name=state type=text  size=15 ><BR>';
 $text4 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12>Job Description:<br>';
 $text4 .= '<textarea name=jobdata rows=8 wrap=VIRTUAL cols=50 ></textarea><p>';
 $text4 .= '<input type=hidden name=markID value=$markID />';
 $text4 .= '<input type=hidden name=e-mail value=$e-mail />';
 $text4 .= '<input type=hidden name=enter1 value=true />';
 $text4 .= '<input type=Submit value=Send Invite > </form>';
  echo $text4;
 }
?></div><BR>

  ==========================================<P>
<div><?php
$enroll_stat = $row1['enroll'];

If ($enroll == 'Yes'){
echo "2-Mark has enrolled on ".$row1['sign_date']."!";
}elseif ($enroll == 'No'){
$text5 .= '<form method=POST action=enter2.php>';
$text5 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12>Add Candidate ID#:  <input name=candidateID type=text  size=16 ><BR>';
$text5 .= '<input type=hidden name=markID value=$markID />';
$text5 .= '<input type=hidden name=enter2 value=true />';
$text5 .= 'Enroll Status: <input type=Submit value=Update >';
$text5 .= '</form><p>';
 echo $text5;
}
?></div> <br>
==========================================<P>

<?php
$pitch_boss = $row1['pitch_bs'];
if ($row1['pitch_bs'] == 'Yes') {
 echo "3-E-mail pitch has been sent to employer on ".$row1['empl_date']."!";
 }
 elseif ($row1['pitch_bs'] == 'No') {
$text6 .= '<div>Scenario - Web Apply:<BR>';
$text6 .= '<form method=POST action=enter3.php>';
$text6 .= '<input type=hidden name=markID value=$markID />';
$text6 .= '<input type=hidden name=enter3 value=true />';
$text6 .= 'Job Application Status: <input type=Submit value=Update >';
$text6 .= '</form></div><p>';
$text6 .= '_______________________________________________<P>';
$text6 .= '<div>Scenario - Direct Apply:<BR>';
$text6 .= '<form method=POST action=enter4.php>';
$text6 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12>HR E-mail: <BR>';
$text6 .= '<input name=hr_mail type=TEXT size=41 ><BR>';
$text6 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12>Portfolio ID: <BR>';
$text6 .= '<input name=portID type=TEXT size=15 ><BR>';
$text6 .= '<IMG height=10 src=images/arrow_orange_trans.jpg width=12>Job Title: <BR>';
$text6 .= '<input name=job_title type=TEXT size=41 ><BR>';
$text6 .= '<input type=hidden name=markID value=$markID />';
$text6 .= '<input type=hidden name=enter4 value=true />';
$text6 .= '<input type=Submit value=Update >';
$text6 .= '</form></div><p>';
 echo $text6;
}
?>
Everything appears normal on the page. But when you try to submit. Glitch!!! :banghead:
Please enlighten me as to the error of my ways.

Thanks in advance.
Batoe

Re: PHP Form fiasco

Posted: Sun Dec 05, 2010 2:59 pm
by califdon
When you view the page created by this code, look at the source HTML. Are the form beginning and ending tags correct, and are the submit input tags correct? The code looks correct to me, but I would want to see what HTML is generated when you actually serve the page to the browser.

Re: PHP Form fiasco

Posted: Mon Dec 06, 2010 1:18 pm
by cap2cap10
Thanks, I found a solution. I rearranged the forms allowing the scripts to work properly.

Thanks again,

Batoe