calumn
New Member
Hello.
I am writing a php script for someone. The script will let the user create html forms that email it to their email.
They enter their email and how many questions they want and hit submit.
It then goes to the next part where a loop creates text boxes on the screen that the user will type the questions in and choose whether they want the questions to have a text box or a large text area.
They then hit submit and it goes to the php page which will create the html form file and a php script that will email the results to them. So far I am trying to get the script to create the html form.
The code is working and doesn't give a php error, but whenever the user chooses a large text area everything after that is automatically put into the large text area and no more html is created.
This is the php code:
I have added lots of comments so you know what it is doing.
This is a page which shows what happens to the form when it is created:
http://www.computalk.net/thegrrlforms/form3.html
As you can see, all the html code after the text area is inside the text area.
I would be very grateful for any help.
Thanks
Calum
I am writing a php script for someone. The script will let the user create html forms that email it to their email.
They enter their email and how many questions they want and hit submit.
It then goes to the next part where a loop creates text boxes on the screen that the user will type the questions in and choose whether they want the questions to have a text box or a large text area.
They then hit submit and it goes to the php page which will create the html form file and a php script that will email the results to them. So far I am trying to get the script to create the html form.
The code is working and doesn't give a php error, but whenever the user chooses a large text area everything after that is automatically put into the large text area and no more html is created.
This is the php code:
PHP:
<?php
require("../config.php"); //require config file for details of admin (email etc._
$fields = $_REQUEST['fields'] ; //fields turned from array to standard variable
$formname = $_REQUEST['formname'] ; //name of form turned from array to standard variable
$formemail = $_REQUEST['formemail'] ; //email of form turned from array to standard variable
$formaccessname = $_REQUEST['formaccessname'] ; //access name turned from array to standard variable
echo'Writing form file 1.';
$filename = "../" . $formaccessname . ".html"; //creates the file with the name the user chose
$newfile = fopen($filename, "w+") or die ("Couldn't access file (is it writable?)"); //opens the file
$newstring .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; //adds html to the file
$newstring .= '<html xmlns="http://www.w3.org/1999/xhtml">'; //adds html to the file
$newstring .= '<head>';//adds html to the file
$newstring .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';//adds html to the file
$newstring .= '<title>' . $formname . '</title>';//adds html to the file
$newstring .= '</head><body>';//adds html to the file
$newstring .= '<form action="' . $formaccessname . 'process.php" method="post">';//adds html to the file
$i=1; //start of counter for while loop
while($i<=$fields) //the while loop loops until it has created all the fields the user wanted
{
$newstring .= $_REQUEST['field' . $i . 'name'] . ': ';//Writes the name of the field to the html page (eg. Name:)
if ($_REQUEST['field' . $i . 'type']=="text"){ //finds out whether user wants a text area or text box, if it is text box it does this:
$newstring .= '<input name="'; //start of textbox
$newstring .= $_REQUEST['fieldshort' . $i . 'name']; //writes the name of the field from the previous form, the $i is so it knows which number
$newstring .= ' type="text" /><br />'; //end of field, new line
}
else{ //if it isn't a textbox
$newstring .= '<textarea name="'; //start of textarea
$newstring .= $_REQUEST['fieldshort'" . $i . 'name']; //writes the name of the field from the previous form, the $i is so it knows which number
$newstring .= ' cols="40" rows="6" /><br />'; //end of field, new line
}
$i++; //adds 1 to the counter
}
$newstring .= '<input name="Submit" type="submit" value="Submit" /></body></html>'; //end of html
@fwrite ($newfile, $newstring) or die ("Couldn't write config.php file (is it writable?)"); //writes the file
fclose ($newfile); //new file
$i=1; //sets i to 1
while($i<=$fields)
{
//space to create the php process page when I need it
$i++;
}
?>
I have added lots of comments so you know what it is doing.
This is a page which shows what happens to the form when it is created:
http://www.computalk.net/thegrrlforms/form3.html
As you can see, all the html code after the text area is inside the text area.
I would be very grateful for any help.
Thanks
Calum