Jump to content

Recommended Posts

advance thank you...

 

i am creating a dynamic form where the from will be four form's created with a switch and

using a array...

 

i am getting a strang error with the switch

 

the error points to the break; statement <<<<

 

current error >>>>>>> Fatal error: Cannot break/continue 1 level in <<<<<<<,

 

please help cheers....

 

<?php

$form=array("<textarea name='note' rows='20' cols='40'> </textarea>",
            "<input type='submit' name='submit' value='SUBMIT ENQUIRE'>",
            "<input type='hidden' name='enquire_type' value='$enquire_type'>",
            "<input type='text' name='name'>",
            "<input type='text' name='telphone'>",
            "<input type='text' name='email'>");

if($_POST['submit']){

$enquire_type=$_POST['enquire_type'];

switch ($enquire_type){

case General_enquire;

echo"<form method='POST' action=' '>

<br>
<font color='red'>This is a $enquire_type!</font>
".$form[2]."
<br><br>

Name!
<br>
".$form[3]."
<br><br>
Email!
<br>
".$form[4]."
<br><br>
Tel Number!
<br>
".$form[5]."
<br><br>
State your enquire!
<br>
".$form[0]."
<br><br>
".$form[1]."
</form>";
exit;
  }
  break;
}
  ?>

<form method="POST" action "">
<br><br>
Please provide enquire type!
<br><br>
<select name="enquire_type">
<option value="General_enquire">General Enquire</option>
<option value="Computer_repairs">Computer Repairs</option>
<option value="Flat_pack_enquire">Flat Pack Enquire</option>
<option value="Audio_installation">Audio Installation</option>
</select>
<input type="submit" name="submit" value="SEND">
</form>

Link to comment
https://forums.phpfreaks.com/topic/107918-php-dynamic-form-please-help/
Share on other sites

code corrected .........

 

now i need to inplement the other 3 forms dynamickly..........


<b>Computer Maintenance - Audio Visual Installation</b>

<?php

$form=array("<textarea name='note' rows='20' cols='40'> </textarea>",
            "<input type='submit' name='submit' value='SUBMIT ENQUIRE'>",
            "<input type='hidden' name='enquire_type' value='$enquire_type'>",
            "<input type='text' name='name'>",
            "<input type='text' name='telphone'>",
            "<input type='text' name='email'>");

if($_POST['submit']){

$enquire_type=$_POST['enquire_type'];

switch ($enquire_type){

case General_enquire;

echo"<form method='POST' action=' '>

<br>
<font color='red'>This is a $enquire_type!</font>
".$form[2]."
<br><br>

Name!
<br>
".$form[3]."
<br><br>
Email!
<br>
".$form[4]."
<br><br>
Tel Number!
<br>
".$form[5]."
<br><br>
State your enquire!
<br>
".$form[0]."
<br><br>
".$form[1]."
</form>";
exit;
break;
  }
  
}
  ?>

<form method="POST" action "">
<br><br>
Please provide enquire type!
<br><br>
<select name="enquire_type">
<option value="General_enquire">General Enquire</option>
<option value="Computer_repairs">Computer Repairs</option>
<option value="Flat_pack_enquire">Flat Pack Enquire</option>
<option value="Audio_installation">Audio Installation</option>
</select>
<input type="submit" name="submit" value="SEND">
</form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.