Jump to content

pcw

Members
  • Posts

    285
  • Joined

  • Last visited

    Never

Everything posted by pcw

  1. I think you are confused between php and html. This looks like you have written the page in html. Therefore <left> should be <p align="left"> and <right> should be <p align="right"> You form action is to a php file which is ok. Email me at pwithers2009@hotmail.co.uk if you are looking for help in writing it in html or using html in a php page.
  2. Hi, thanks for your reply, but this just adds blank fields to the database
  3. I have tried using this to add the results to the database, but its not adding anything. If I change the variables, it just adds blank fields. Any ideas? <?php $link = mysql_pconnect( "localhost", $dbuser, $dbpass ); if ( ! $link ) { $dberror = mysql_error(); return false; } if ( ! mysql_select_db( $db, $link ) ) { $dberror = mysql_error(); return false; } $query = "INSERT INTO FormFields ( name, type ) values('$name', '$vbCrLf').$vbCrLf"; if ( ! mysql_query( $query, $link ) ) { $dberror = mysql_error(); return false; } return true; }; ?>
  4. <?php $age = $_POST['age']; if ($age > 16 && $age < 26 ) { print "age ok"; } else { print "wrong age"; } print <<<END <form method="POST"> age: <input type="text" name="age"> <input type="submit" name="submit" value="submit"> END; ?> Thats how you would check the age is correct
  5. Hi Keith, thanks again, that is just what I needed. I am just confused as to what the variables for the separate field name and field type are. Whereas I was using ShowName and ShowType to print the results in the database, what variables would I use now? Thanks
  6. Hi Keith, I tried what you said, but it kept printing out the same data in the previewarea, and didnt state the form name and form field above. ie. it kept printing <input type="text" name="firstname"> <input type="text" name="firstname"> etc - in the previewarea I made a change to it and the results appear correctly in the previewarea, but it does not print the form name and form field above. This is what I got now: <?php $db = "moveitho_sitebuilder"; $dbuser = "moveitho_paul"; $dbpass = "test"; $optionCnt = 0; if ($_POST['addoption']) { echo '<form name="makeformfield" method="post"> Field Name: <input type="text" name="fieldname" value="'.$_POST['fieldname'].'"> Field Type: <select name="fieldtype"> <option>Text Field</option> <option>Text Area</option> <option>Radio Button</option> <option>Checkbox</option> <option>Select</option> </select><br />'; foreach($_POST as $field => $value) { if (substr($field,0,11) == "optionvalue") { $optionCnt++; echo "<input type='text' name='$field' value='$value' /><br />"; } } echo "<input type='text' name='optionvalue$optionCnt' value='' /><br />"; echo '<p>view code:</p>'; echo '<table border=0>'; foreach($_POST as $field => $value) { if (substr($field,0,9) == "fieldname") { $fieldNumber = substr($field,9); echo '<input type="hidden" name="hiddendata'.$ShowName.'" value="'.$_POST['hiddendata'.$ShowName].'" />'; echo '<input type="hidden" name="hiddendata1'.$ShowType.'" value="'.$_POST['hiddendata'.$ShowType].'" />'; echo "<tr><td>Field Name: ".$_POST['fieldname'.$ShowName]."</td><td>Field Type: ".$_POST['fieldtype'.$ShowType]."</td></tr>"; } } echo "</table>"; echo stripslashes('<textarea cols="60" rows="5" name="previewarea" >'.$_POST['previewarea'].'</textarea>'); echo '<br /><input type="submit" name="update" value="update"><input type="submit" name="submit" value="submit"> <input type="submit" name="addoption" value="addoption">'; } else { echo '<form name="makeformfield" method="post"> Field Name: <input type="text" name="fieldname"> Field Type: <select name="fieldtype"> <option>Text Field</option> <option>Text Area</option> <option>Radio Button</option> <option>Checkbox</option> <option>Select</option> </select><br />'; echo "<input type='text' name='optionvalue$optionCnt' value='' /><br />"; if ($_POST['update']) { $option = $_POST['field_options']; $type = $_POST['fieldtype']; $name = $_POST['fieldname']; if ($type == 'Text Field') { $NewField = '<input type="text" name="'.$name.'" />'; } if ($type == 'Text Area') { $NewField = '<textarea cols="5" rows="4" name="'.$name.'"></textarea>'; } if ($type == 'Radio Button') { $NewField = '<input type="radio" name="'.$name.'" />'; } if ($type == 'Checkbox') { $NewField = '<input type="checkbox" name="'.$name.'" />'; } if ($type == 'Select') { $NewField = '<select name="'.$name.'" />'.chr(13); foreach($_POST as $field => $value) { if (substr($field,0,11) == "optionvalue") { $NewField .= '<option>'.$value.'</option>'.chr(13); } } $NewField .= '</select>'; } echo '<p>view code:</p>'; echo '<table border=0>'; foreach($_POST as $field => $value) { if (substr($field,0,9) == "fieldname") { $fieldNumber = substr($field,9); echo '<input type="hidden" name="fieldname'.$fieldNumber.'" value="'.$_POST['fieldname'.$fieldNumber].'" />'; echo '<input type="hidden" name="fieldtype'.$fieldNumber.'" value="'.$_POST['fieldtype'.$fieldNumber].'" />'; echo "<tr><td>Field Name: ".$_POST['fieldname'.$fieldNumber]."</td><td>Field Type: ".$_POST['fieldtype'.$fieldNumber]."</td></tr>"; } } echo "</table>"; echo stripslashes('<textarea cols="60" rows="5" name="previewarea" >'.$_POST['previewarea'].chr(13).$NewField.'</textarea>'); echo '<br /><input type="submit" name="update" value="update"><input type="submit" name="submit" value="submit"> <input type="submit" name="addoption" value="addoption">'; } else { echo stripslashes('<textarea cols="60" rows="5" name="previewarea" ></textarea>'); echo '<br /><input type="submit" name="update" value="update"><input type="submit" name="submit" value="submit"> <input type="submit" name="addoption" value="addoption">'; } } echo '</form>'; if ($_POST['submit']) { $ShowName = $_POST['hiddendata']."Field Name: $name"; echo '<input type="hidden" name="hiddendata" value="'.$ShowName.'" />'; $ShowType= $_POST['hiddendata1']."Field Type: $type"; echo '<input type="hidden" name="hiddendata1" value="'.$ShowType.'" />'; $write = stripslashes(''.$_POST['previewarea'].chr(13).$NewField.''); $filename = "data/fields.txt"; $fa = fopen( $filename, "w" ) or die("Error opening $filename"); fwrite( $fa, "$write" ); fclose( $fa ); $link = mysql_pconnect( "localhost", $dbuser, $dbpass ); if ( ! $link ) { $dberror = mysql_error(); return false; } if ( ! mysql_select_db( $db, $link ) ) { $dberror = mysql_error(); return false; } $query = "INSERT INTO FormFields ( name, type ) values('$ShowName', '$ShowType')"; if ( ! mysql_query( $query, $link ) ) { $dberror = mysql_error(); return false; } return true; }; ?>
  7. I have tried this instead, and am still getting the same sort of result. <?php echo '<p>view code:</p>'; $ShowName = $_POST['hiddendata']."$name"; echo '<input type="hidden" name="hiddendata" value="'.$ShowName.'" />'; $ShowType= $_POST['hiddendata1']."$type"; echo '<input type="hidden" name="hiddendata1" value="'.$ShowType.'" />'; echo '<table border=0>'; foreach($_POST as $name) { echo "<tr><td>Field Name: $ShowName</td><td>Field Type: $ShowType</td></tr>"; echo "</table>"; } ?> Can anybody tell me why it prints it more than once each time the form is updated? Thanks Thanks
  8. $file_name=$_POST['Lname'].$_POST['Tid']; Should work
  9. Its ok, done it now, thanks
  10. <?php print "<select name=\"year\">"; print "<option value=\"<?php echo 'date(Y)' echo 'selected';?><?php echo date(Y);?></option>"; print "<option value=\"2009\">2009</option>"; print "<option value=\"2010\">2010</option>"; print "</select>"; ?> Thats should do it
  11. www.smarty.net supplies all the documentation you need, and its very simple
  12. Hi, I got this section of a script. I need to print the field name and type within table tags, but am getting an unexpected result: Here is the section of the script: <?php $optionCnt = 0; if ($_POST['addoption']) { echo '<form name="makeformfield" method="post"> Field Name: <input type="text" name="fieldname" value="'.$_POST['fieldname'].'"> Field Type: <select name="fieldtype"> <option>Text Field</option> <option>Text Area</option> <option>Radio Button</option> <option>Checkbox</option> <option>Select</option> </select><br />'; foreach($_POST as $field => $value) { if (substr($field,0,11) == "optionvalue") { $optionCnt++; echo "<input type='text' name='$field' value='$value' /><br />"; } } echo "<input type='text' name='optionvalue$optionCnt' value='' /><br />"; $ShowName = $_POST['hiddendata']."$name"; echo '<input type="hidden" name="hiddendata" value="'.$ShowName.'" />'; $ShowType= $_POST['hiddendata1']."$type"; echo '<input type="hidden" name="hiddendata1" value="'.$ShowType.'" />'; echo '<table border=0>'; foreach($_POST as $ShowName) { echo "<tr><td>Field Name: $ShowName</td>"; } foreach($_POST as $ShowType) { echo "<td>Field Type: $ShowType</td></tr>"; } echo stripslashes('<textarea cols="60" rows="5" name="previewarea" >'.$_POST['previewarea'].'</textarea>'); echo '<br /><input type="submit" name="update" value="update"><input type="submit" name="submit" value="submit"> <input type="submit" name="addoption" value="addoption">'; } ?> The result I get when submitting the form is: Field Name: first name Field Name: Text Field Field Name: Field Name: Field Name: update Field Type: first name Field Type: Text Field Field Type: Field Type: Field Type: update Instead of Field Name: First Name Field Type: Text Field Can anyone tell me how to fix this?
  13. Try mysql_query("INSERT INTO user_info ( 'id' , 'username' , 'password' , 'email' , 'money' , 'bullets' , 'points' , 'health' , 'rank' , 'rankpoints' , 'weapon' , 'armour' , 'plane' , 'location' , 'ip' , 'userlevel' ) VALUES ( '', '$reg_username', '$randomPass' , '$email' , '10000' , '0' , '0' , '100' , 'Civillian', '0' , 'None' , 'None' , 'None' , '$location' , '$ip' , '1' )"; } }}}}}
  14. Hi, Is it possible to split $DisplayInfo so it prints: Field Name and Field Type separately? I need to do this so I can write the results to mysql database. Cant seem to figure out how to split it. Thanks
  15. Hi Jack, tried changing it to onclick, but no success. I think I will give it a go using keiths way, as I had a change of plan. Thanks to both, for your help
  16. That done the trick. Thanks very much for your help Keith, you been a star
  17. Hi, I would like to print the result of every field submitted, how is this done?
  18. Thanks, this is the code that is from the part of the script with the prob: <?php $optionCnt = 0; if ($_POST['addoption']) { echo '<form name="makeformfield" method="post"> Field Name: <input type="text" name="fieldname" value="'.$_POST['fieldname'].'"> Field Type: <select name="fieldtype"> <option>Text Field</option> <option>Text Area</option> <option>Radio Button</option> <option>Checkbox</option> <option onClick="window.open(\'addfield.php\')">Select</option> </select><br />'; foreach($_POST as $field => $value) { if (substr($field,0,11) == "optionvalue") { $optionCnt++; echo "<input type='text' name='$field' value='$value' /><br />"; } } echo "<input type='text' name='optionvalue$optionCnt' value='' /><br />"; echo stripslashes('<textarea cols="60" rows="5" name="previewarea" >'.$_POST['previewarea'].'</textarea>'); echo '<br /><input type="submit" name="update" value="update"><input type="submit" name="submit" value="submit"> <input type="submit" name="addoption" value="addoption">'; }?> I cant understand why the popup is not working
  19. That cured the error, but the popup does not open. Should this work fine in a PHP script?
  20. That is along the lines of what I want: <option onclick="window.open('addfield.php')">Select</option> But I get this error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/moveitho/public_html/sitebuilder/testform1.php on line 14 If I change it to this: <option onclick="window.open(addfield.php)">Select</option> The page loads without errors but the popup doesnt appear. Do I need to include tags for javascript like you have to do with php? eg <?php and ?>
  21. Hi Jack, I only want the popup to appear if the uses clicks on the 'Select' option in the menu. The rest of the options should not do anything as the rest of the script handles them. Is that poss?
  22. Hi Jack, thanks for your reply. I dont really know anything about javascript. I tried with what you suggested, but have got it wrong, and keep getting errors. Field Type: <select name="fieldtype"> <option>Text Field</option> <option>Text Area</option> <option>Radio Button</option> <option>Checkbox</option> <option onchange="window.open('addfield.php')">Select</option> </select><br />'; What should this code be? Thanks
  23. Hi, I was wondering if it was possible to create a popup window that appears when a certain value is selected from a select menu. I have this select field: Field Type: <select name="fieldtype"> <option>Text Field</option> <option>Text Area</option> <option>Radio Button</option> <option>Checkbox</option> <option>Select</option> </select><br />'; It is part of a dynamic form script that I would like to appear tidier to the user. Therefore, I would like a popup window to appear when the user selects Select from the menu. Is this possible without the user having to submit the request first?
  24. Any idea on how I print these?
  25. Just one more question, is it possible to print the formfield name and type, above the previewarea? eg. After adding formfield and fieldtype, it prints: Field Name: First Name Field Type: Text Field I have tried: <?php foreach($_POST as $name => $value) { print "$value"; } ?> But it prints a lot of input boxes. Thanks for your help
×
×
  • 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.