php coding problem - reference numbers on forms

  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

is it possible to have a sequencial reference number be generated on a form each time it is submitted. the user doesnt have to put the number in there. it should be generated. ie if the starting number was 'X200' is it possible for the next form to have the referennce number be 'X201' then 'X202' then 'X203' and so on.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

How are the ref's being used? I ask because it makes a difference whether they are stored in a DB or not. If they are, you can let the database generate the number, ref == key. If not then it will depend on the method of use.
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i would like to database to generate the number. but the number will have a letter prefix
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Will the prefix alter, or are you just looking to have a specific letter then a number so you know what TYPE of infrmation is there? Assuming the later:

Will you be storing the posted forms into the database or not. All of what I have read suggests not. If you actually <b>need</b> the form input to go into a database then just set up your database as normal with a unique key. You just add the letter outside of the database.

If you don't store in a database, then keep the number in a text file and increment that.
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

ok, yes i want to have a letter then a number like A200 and incrementing by 1, or W300 and incrementing by 1. 'A' would be for 'accounts opened' and 'W' would be for 'Work done' and so on. in order to flick thru the forms to see what has numbers have gone or to see what number has been allocated to which person, a database might be needed for it. what do you think?

what do you mean by 'adding a letter outside the database? is it the same as adding a letter to an incremental variable or do they not exist?
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

on another note entirely. i have this code
[php]$errors = array();

foreach ($required_fields as $value)
{
if (!isset($_POST[$value]) || (isset($_POST[$value]) && !$_POST[$value]))
{
$errors[] = $required_fields[$value];
}
}

if ($errors)
{
echo 'you forgot to fill in ' . count($errors) . ' required fields:<br><br>Click your back button to fill in the missinh fields';
foreach ($errors as $value)
{
echo $value . '<br>';
}
}

else
{ [/code]

it works fine. this is the message that comes up when an error has been found
"you forgot to fill in 13 required fields:" the script seems to count up the errors then display how much its counted. what i would like it to do is to also display the errors. like: "you forgot to fill in your name" or "you forgot to fill in your email address"

counting the nubers is fine, i want the user what exact errors they made so they can go back and fill in those areas. the coed also doesnt keep the code in the form once its highlighted the error
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

Okay this problem would only be solved by proper DB normalization

First up you would have a table with the work to be done etc.
The PK row would auto-increment your numbers, next you would have table called something like work_type. This would contain the prefixes of the numbers you want to generate and a helpf ul description (eg. w - work). The ID for the work_type would be inserted into the table containing the numbers and when you want to check the numbers and include the prefix you would do an inner join select statement.

That would be more or less the right way to do it.

An easier way but not as efficient. have a PK field that auto-increments and a field that contains the prefix, then when you call a set of result concatenate the two ie join them together. The DB doesn't need to know the prefix, only you do so it doesn't matter how it is stored as long as when you view the results it makes sense
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

by outside the database I mean, store the number in the database, and when you output the number, concatanate the letter on to it. This will work if your A's and B's and whatever are in different databases.

If they are all in th same database, the alternative is to use php to calculate the highest existing value and then increment it. Rough and ready SQL:

Code: [ Select ]
SELECT UniqueKey
FROM TheTable
WHERE UniqueKey LIKE 'x*'
ORDER BY UniqueKey DESC;
  1. SELECT UniqueKey
  2. FROM TheTable
  3. WHERE UniqueKey LIKE 'x*'
  4. ORDER BY UniqueKey DESC;


The star may be wrong, I have been working with the access SQL dialect recently, it may be a % I'm not sure - check it though.

That will return the highest record begining with an x. So X101 or whatever, you then extract the number. add one, then whack an x on the front again - jobs a good'un.

//edit, I'm not entirely sure how normalisation helps in this case RD, the method you suggest would not give W1, W2, W3, A1, A2, A3, it would give, W1, W2, A3, W4, A5, A6, because it incrementing the number without consideration for the letter prefix.
However, the link to useful names is a good idea, I would probably go for a compound key thinking about it, but still work out the number using PHP.


As for the errors thing, I assume you are using something like:
PHP Code: [ Select ]
 
$required_fields= array(
 
    "name" -> "",
 
    "address" -> ""
 
)
 
 
  1.  
  2. $required_fields= array(
  3.  
  4.     "name" -> "",
  5.  
  6.     "address" -> ""
  7.  
  8. )
  9.  
  10.  


instead use:

PHP Code: [ Select ]
 
$required_fields = array(
 
    "name" -> "You forgot to add a name, retard",
 
    "address" -> "Tell me where you live"
 
)
 
 
  1.  
  2. $required_fields = array(
  3.  
  4.     "name" -> "You forgot to add a name, retard",
  5.  
  6.     "address" -> "Tell me where you live"
  7.  
  8. )
  9.  
  10.  


Then as you loop through the errors, build a string:

PHP Code: [ Select ]
 
$errorString = "you made the following errors:<br />"
 
foreach ($required_fields as $value -> $message){
 
    if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value])){
 
        $errorString+= $message."<br />";
 
    }
 
}
 
 
  1.  
  2. $errorString = "you made the following errors:<br />"
  3.  
  4. foreach ($required_fields as $value -> $message){
  5.  
  6.     if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value])){
  7.  
  8.         $errorString+= $message."<br />";
  9.  
  10.     }
  11.  
  12. }
  13.  
  14.  
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

Code: [ Select ]
SELECT MAX(int_row)
FROM table
WHERE letterRow LIKE 'a%'
  1. SELECT MAX(int_row)
  2. FROM table
  3. WHERE letterRow LIKE 'a%'


This is a slightly more efficient statement I think (no offense rtm - if it is wrong feel free to flame)

You where right about the normalization though but I would probaby have normalized it anyway for good house keeping.

I had the same problem on a system I built for logging CD's with backup work on them.

Slightly more complicated though because multiple clients could be backed up on one CD. That is why normilization came about in this topic.

Anyways this statement should return the top number, then what you do is just add one and away you go (for the numbers at least)
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Rabid Dog wrote:
Code: [ Select ]
SELECT MAX(int_row)
FROM table
WHERE letterRow LIKE 'a%'
  1. SELECT MAX(int_row)
  2. FROM table
  3. WHERE letterRow LIKE 'a%'


This is a slightly more efficient statement I think (no offense rtm - if it is wrong feel free to flame)

Flame? No. You are right, it's a better SQL statement lol so no offense taken :D Thank you correcting the wildcard thing, may microsoft rot and burn in hell....

As for normalisation, I would go for a int_row, and work_id, with the work_id linked to a "definition table", with work_id and work_description in it, just because it's a good idea. As far as I'm aware that does not violate any of the normalisation rules, although I tend to go on instinct with normalisation....
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

That is porbably the way I would do it as well but I have no paper or pen to plan it :cry:

To tired to even try LOL
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

//rtm223 i am getting this error "Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in /path/to/url/getstartedformtrial3.php on line 58".

line 58 in my code is this line:
Code: [ Select ]
$required_fields = array("name" -> "You forgot to add a name, retard", "address" -> "Tell me where you live");
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i dont think it likes the '->' symbol. its chucking errors out because of it
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Well of course it doesn't like the -> symbol, because it doesn't even exist. => is what I was looking for.

*slaps forehead* :lol:
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

Parse error: parse error, unexpected T_FOREACH in /path/to/url/getstartedformtrial3.php on line 54

error is this:
Code: [ Select ]
foreach ($required_fields as $value => $message){


this one is strnge tho
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

whats on the lines before?
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

ok, i got past that foreach error. turned out that there wasnt a ';' at the end of the previous line. what i am getting thos is this:

'Parse error: parse error, unexpected T_ELSE in /path/to/url/getstartedformtrial3.php on line 45'

PHP Code: [ Select ]
foreach ($required_fields as $value => $message)
 
{
 
    if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value]))
 
   {
 
        $errorString+= $message."<br />";
 
    }
 
}
 
else //this is where the error at line 45 is
 
{//carry on
  1. foreach ($required_fields as $value => $message)
  2.  
  3. {
  4.  
  5.     if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value]))
  6.  
  7.    {
  8.  
  9.         $errorString+= $message."<br />";
  10.  
  11.     }
  12.  
  13. }
  14.  
  15. else //this is where the error at line 45 is
  16.  
  17. {//carry on
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Thats what I thought ;)

well you have a:
PHP Code: [ Select ]
 
foreach(){
 
    //stuff
 
}else{
 
 
  1.  
  2. foreach(){
  3.  
  4.     //stuff
  5.  
  6. }else{
  7.  
  8.  


structure going on, check out the bracket order
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i am having a hair pulin out time trying to figure this bracket thing out. just wjen i thought ihave sorted it i run it and find that the validation has been totally omitted. when i put the brakcets and ELSE back in i get errors. no matter how i do this i seem to get errors on different lines.

would you mind if i posted the wholecode up for you to take a look at? i should have had this finished for my boss 2day so hopefully by 2night i can get this finished.

reply back and let me know please.

thank you
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

now its not even taking into consideration the 'foreach' statement

HELP!!
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

I tend to stick to indexed array's.

the required_fields array is an indexed array if I remember correctly which means it will be accessed like
PHP Code: [ Select ]
 
for ($i=0;$i<count($required_fields);$i++){
 
      $output = $required_fields[$i]; // Place code here
 
}
 
 
  1.  
  2. for ($i=0;$i<count($required_fields);$i++){
  3.  
  4.       $output = $required_fields[$i]; // Place code here
  5.  
  6. }
  7.  
  8.  


another thing, PHP doesn't use the '+' operator to concatenate strings.

to concatenate like that you would use '.=' not '+='
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

I'm gonna stop posting code that I havn't tested, I get far too confused between languages - thanks for catching that one RD.

We used associatives because the code was using isset to see if the variable is required, and then using the value of it as the error message. You need an associative array to do both parts.

Quote:
i am having a hair pulin out time trying to figure this bracket thing out.

The curly brackets are blocks, when I last posted you had an if/else block overlapping a foreach block. Which was what I was pointing out.

Try running through it in your head - it's just not possible. The brackets are all simple, it's just splitting into logical blocks, which have to be properly nested.
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

this is what i have. this is what is bugging me:

Code: [ Select ]
if ($_POST['submit'])
{
$user="";
$host="";
$password="";
$database="";//then other database stuff
foreach //foreach statement dadadada
{
if //isset statements
{
final statement
}
}
mail($_POST['email'],'hello there','Hello '.$_POST['name'].', thank you for filling out the form ', "From: email@address.com");
echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext><tr><td>";
echo 'Hello '.$_POST['name'].', thank you for filling out the form ';
echo "</tr></td></table>";
echo "<body onLoad=redirect() text=#000000 link=#00FFFF vlink=#C0C0C0>";
}else{

?>
<body> //actual form
</body>
<?
}
?>
  1. if ($_POST['submit'])
  2. {
  3. $user="";
  4. $host="";
  5. $password="";
  6. $database="";//then other database stuff
  7. foreach //foreach statement dadadada
  8. {
  9. if //isset statements
  10. {
  11. final statement
  12. }
  13. }
  14. mail($_POST['email'],'hello there','Hello '.$_POST['name'].', thank you for filling out the form ', "From: email@address.com");
  15. echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext><tr><td>";
  16. echo 'Hello '.$_POST['name'].', thank you for filling out the form ';
  17. echo "</tr></td></table>";
  18. echo "<body onLoad=redirect() text=#000000 link=#00FFFF vlink=#C0C0C0>";
  19. }else{
  20. ?>
  21. <body> //actual form
  22. </body>
  23. <?
  24. }
  25. ?>
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Every block starts and ends with a curly bracket, if you don't have the same number of opening brackets as closing, you are buggered.

I would suggest you are struggling with brackets because you are not using whitespace:
PHP Code: [ Select ]
if ($_POST['submit']){
 
   $user="";
 
   $host="";
 
   $password="";
 
   $database="";//then other database stuff
 
   foreach {
 
      if{
 
         final statement
 
      }
 
   }
 
//}-this close bracket is missing!!
 
 
  1. if ($_POST['submit']){
  2.  
  3.    $user="";
  4.  
  5.    $host="";
  6.  
  7.    $password="";
  8.  
  9.    $database="";//then other database stuff
  10.  
  11.    foreach {
  12.  
  13.       if{
  14.  
  15.          final statement
  16.  
  17.       }
  18.  
  19.    }
  20.  
  21. //}-this close bracket is missing!!
  22.  
  23.  


If you use whitespace to tab your blocks in you can see where they start and end and you can see straight away where problems are. As my old maths teacher used to say:

Mr Turner wrote:
Neatness is an insurance policy against making mistakes

Keep your code neat and it's easier to see where you have gone wrong.
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

when i put the extra bracket in i get this error:

'Parse error: parse error, unexpected '}' in /path/to/url/getstartedformtrial3.php on line 48'

the code i put up has 4 open brackets and 4 closed brackets. i dont understand what is going on. yes there is some nested stuff going on. that maybe what is the confusing factor.

Code: [ Select ]
<?php
if{
foreach{
if{
}
}
}else{
?>
<body>
</body>
<?
}
?>
  1. <?php
  2. if{
  3. foreach{
  4. if{
  5. }
  6. }
  7. }else{
  8. ?>
  9. <body>
  10. </body>
  11. <?
  12. }
  13. ?>


i am stuck. i am sure the code is so close to working as well.
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

what's in all the if's and foreach's? It could be a problem in them?
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

Code: [ Select ]
<?php

//extract($_REQUEST);

if ($_POST['submit']){
$user="";
$host="";
$password="";
$database="";
$connection=mysql_connect($host,$user,$password) or die ("could not connect to server");
$$sql = "insert into gstrialforma(name, email, contactaddress, mobile, workhometel, contactpostcode, projectpostcode, doyouneed, designstyle, project, uses, engineer, partywall, architect, projectmanager, design, lifestyle, structural, planning, buildingregs, otherhelp, wheelchair, partialeyesight, terraced, familychildern, semidetached, aged, allergy, detached, other, otherneeds, specifyneeds, programtimecompletion, budgetcost, projectdeadline, whybuild, otherpreferences) values ('{$_POST['name']}','{$_POST['email']}','{$_POST['contactaddress']}','{$_POST['mobile']}','{$_POST['workhometel']}','{$_POST['contactpostcode']}','{$_POST['projectpostcode']}','{$_POST['doyouneed']}','{$_POST['designstyle']}','{$_POST['project']}','{$_POST['uses']}','{$_POST['engineer']}','{$_POST['partywall']}','{$_POST['architect']}','{$_POST['projectmanager']}','{$_POST['design']}','{$_POST['lifestyle']}','{$_POST['structural']}','{$_POST['planning']}','{$_POST['buildingregs']}','{$_POST['otherhelp']}','{$_POST['wheelchair']}','{$_POST['partialeyesight']}','{$_POST['terraced']}','{$_POST['familychildern']}','{$_POST['semidetached']}','{$_POST['aged']}','{$_POST['allergy']}','{$_POST['detached']}','{$_POST['other']}','{$_POST['otherneeds']}','{$_POST['specifyneeds']}','{$_POST['programtimecompletion']}','{$_POST['budgetcost']}','{$_POST['projectdeadline']}','{$_POST['whybuild']}','{$_POST['otherpreferences']}')";
$result = mysql_query($sql) or print(mysql_error());
                        //mail($to, $subject, $msg, $additional_headers);
$required_fields = array("name" => "You forgot to add a name, retard", "address" => "Tell me where you live");
$errorString = "you made the following errors:<br />";
foreach ($required_fields as $value => $message){
  if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value])){
             $errorString.= $message."<br />";
        }
}
mail($_POST['email'],'hello there','Hello '.$_POST['name'].', thank you for filling out the form ', "From: athompson@building-doctors.com");
echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext><tr><td>";
echo 'Hello '.$_POST['name'].', thank you for filling out the form ';
echo "</tr></td></table>";
echo "<body onLoad=redirect() text=#000000 link=#00FFFF vlink=#C0C0C0>";
}
}else{
//below is the html form abreviated
?>
<body leftmargin="0" topmargin="0">
<table width="400" height="246" border="0" cellpadding="0" cellspacing="0" class="biggertext">
 <tr>
  <td height="30" valign="top"><form method="POST" action="getstartedformtrial3.php">

<!--the form is here --!>


</form></td>
 </tr>
</table>
</body>
<?
}

?>
  1. <?php
  2. //extract($_REQUEST);
  3. if ($_POST['submit']){
  4. $user="";
  5. $host="";
  6. $password="";
  7. $database="";
  8. $connection=mysql_connect($host,$user,$password) or die ("could not connect to server");
  9. $$sql = "insert into gstrialforma(name, email, contactaddress, mobile, workhometel, contactpostcode, projectpostcode, doyouneed, designstyle, project, uses, engineer, partywall, architect, projectmanager, design, lifestyle, structural, planning, buildingregs, otherhelp, wheelchair, partialeyesight, terraced, familychildern, semidetached, aged, allergy, detached, other, otherneeds, specifyneeds, programtimecompletion, budgetcost, projectdeadline, whybuild, otherpreferences) values ('{$_POST['name']}','{$_POST['email']}','{$_POST['contactaddress']}','{$_POST['mobile']}','{$_POST['workhometel']}','{$_POST['contactpostcode']}','{$_POST['projectpostcode']}','{$_POST['doyouneed']}','{$_POST['designstyle']}','{$_POST['project']}','{$_POST['uses']}','{$_POST['engineer']}','{$_POST['partywall']}','{$_POST['architect']}','{$_POST['projectmanager']}','{$_POST['design']}','{$_POST['lifestyle']}','{$_POST['structural']}','{$_POST['planning']}','{$_POST['buildingregs']}','{$_POST['otherhelp']}','{$_POST['wheelchair']}','{$_POST['partialeyesight']}','{$_POST['terraced']}','{$_POST['familychildern']}','{$_POST['semidetached']}','{$_POST['aged']}','{$_POST['allergy']}','{$_POST['detached']}','{$_POST['other']}','{$_POST['otherneeds']}','{$_POST['specifyneeds']}','{$_POST['programtimecompletion']}','{$_POST['budgetcost']}','{$_POST['projectdeadline']}','{$_POST['whybuild']}','{$_POST['otherpreferences']}')";
  10. $result = mysql_query($sql) or print(mysql_error());
  11.                         //mail($to, $subject, $msg, $additional_headers);
  12. $required_fields = array("name" => "You forgot to add a name, retard", "address" => "Tell me where you live");
  13. $errorString = "you made the following errors:<br />";
  14. foreach ($required_fields as $value => $message){
  15.   if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value])){
  16.              $errorString.= $message."<br />";
  17.         }
  18. }
  19. mail($_POST['email'],'hello there','Hello '.$_POST['name'].', thank you for filling out the form ', "From: athompson@building-doctors.com");
  20. echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext><tr><td>";
  21. echo 'Hello '.$_POST['name'].', thank you for filling out the form ';
  22. echo "</tr></td></table>";
  23. echo "<body onLoad=redirect() text=#000000 link=#00FFFF vlink=#C0C0C0>";
  24. }
  25. }else{
  26. //below is the html form abreviated
  27. ?>
  28. <body leftmargin="0" topmargin="0">
  29. <table width="400" height="246" border="0" cellpadding="0" cellspacing="0" class="biggertext">
  30.  <tr>
  31.   <td height="30" valign="top"><form method="POST" action="getstartedformtrial3.php">
  32. <!--the form is here --!>
  33. </form></td>
  34.  </tr>
  35. </table>
  36. </body>
  37. <?
  38. }
  39. ?>
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

PHP Code: [ Select ]
<?php
 
 
 
//extract($_REQUEST);
 
 
 
if ($_POST['submit']){
 
   $user="";
 
   $host="";
 
   $password="";
 
   $database="";
 
   $connection=mysql_connect($host,$user,$password) or die ("could not connect to server");
 
   $$sql = "insert into gstrialforma(name, email, contactaddress, mobile, workhometel, contactpostcode, projectpostcode, doyouneed, designstyle, project, uses, engineer, partywall, architect, projectmanager, design, lifestyle, structural, planning, buildingregs, otherhelp, wheelchair, partialeyesight, terraced, familychildern, semidetached, aged, allergy, detached, other, otherneeds, specifyneeds, programtimecompletion, budgetcost, projectdeadline, whybuild, otherpreferences) values ('{$_POST['name']}','{$_POST['email']}','{$_POST['contactaddress']}','{$_POST['mobile']}','{$_POST['workhometel']}','{$_POST['contactpostcode']}','{$_POST['projectpostcode']}','{$_POST['doyouneed']}','{$_POST['designstyle']}','{$_POST['project']}','{$_POST['uses']}','{$_POST['engineer']}','{$_POST['partywall']}','{$_POST['architect']}','{$_POST['projectmanager']}','{$_POST['design']}','{$_POST['lifestyle']}','{$_POST['structural']}','{$_POST['planning']}','{$_POST['buildingregs']}','{$_POST['otherhelp']}','{$_POST['wheelchair']}','{$_POST['partialeyesight']}','{$_POST['terraced']}','{$_POST['familychildern']}','{$_POST['semidetached']}','{$_POST['aged']}','{$_POST['allergy']}','{$_POST['detached']}','{$_POST['other']}','{$_POST['otherneeds']}','{$_POST['specifyneeds']}','{$_POST['programtimecompletion']}','{$_POST['budgetcost']}','{$_POST['projectdeadline']}','{$_POST['whybuild']}','{$_POST['otherpreferences']}')";
 
   $result = mysql_query($sql) or print(mysql_error());
 
                  //mail($to, $subject, $msg, $additional_headers);
 
   $required_fields = array("name" => "You forgot to add a name, retard", "address" => "Tell me where you live");
 
   $errorString = "you made the following errors:<br />";
 
   foreach ($required_fields as $value => $message){
 
      if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value])){
 
            $errorString.= $message."<br />";
 
         }
 
   }
 
   mail($_POST['email'],'hello there','Hello '.$_POST['name'].', thank you for filling out the form ', "From: athompson@building-doctors.com");
 
   echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext><tr><td>";
 
   echo 'Hello '.$_POST['name'].', thank you for filling out the form ';
 
   echo "</tr></td></table>";
 
   echo "<body onLoad=redirect() text=#000000 link=#00FFFF vlink=#C0C0C0>";
 
}else{
 
//below is the html form abreviated
 
?>
 
<body leftmargin="0" topmargin="0">
 
<table width="400"  height="246" border="0" cellpadding="0" cellspacing="0" class="biggertext">
 
  <tr>
 
    <td height="30" valign="top"><form method="POST" action="getstartedformtrial3.php">
 
 
 
<!--the form is here -->
 
 
 
 
 
</form></td>
 
  </tr>
 
</table>
 
</body>
 
<?
 
}
 
 
 
?>
  1. <?php
  2.  
  3.  
  4.  
  5. //extract($_REQUEST);
  6.  
  7.  
  8.  
  9. if ($_POST['submit']){
  10.  
  11.    $user="";
  12.  
  13.    $host="";
  14.  
  15.    $password="";
  16.  
  17.    $database="";
  18.  
  19.    $connection=mysql_connect($host,$user,$password) or die ("could not connect to server");
  20.  
  21.    $$sql = "insert into gstrialforma(name, email, contactaddress, mobile, workhometel, contactpostcode, projectpostcode, doyouneed, designstyle, project, uses, engineer, partywall, architect, projectmanager, design, lifestyle, structural, planning, buildingregs, otherhelp, wheelchair, partialeyesight, terraced, familychildern, semidetached, aged, allergy, detached, other, otherneeds, specifyneeds, programtimecompletion, budgetcost, projectdeadline, whybuild, otherpreferences) values ('{$_POST['name']}','{$_POST['email']}','{$_POST['contactaddress']}','{$_POST['mobile']}','{$_POST['workhometel']}','{$_POST['contactpostcode']}','{$_POST['projectpostcode']}','{$_POST['doyouneed']}','{$_POST['designstyle']}','{$_POST['project']}','{$_POST['uses']}','{$_POST['engineer']}','{$_POST['partywall']}','{$_POST['architect']}','{$_POST['projectmanager']}','{$_POST['design']}','{$_POST['lifestyle']}','{$_POST['structural']}','{$_POST['planning']}','{$_POST['buildingregs']}','{$_POST['otherhelp']}','{$_POST['wheelchair']}','{$_POST['partialeyesight']}','{$_POST['terraced']}','{$_POST['familychildern']}','{$_POST['semidetached']}','{$_POST['aged']}','{$_POST['allergy']}','{$_POST['detached']}','{$_POST['other']}','{$_POST['otherneeds']}','{$_POST['specifyneeds']}','{$_POST['programtimecompletion']}','{$_POST['budgetcost']}','{$_POST['projectdeadline']}','{$_POST['whybuild']}','{$_POST['otherpreferences']}')";
  22.  
  23.    $result = mysql_query($sql) or print(mysql_error());
  24.  
  25.                   //mail($to, $subject, $msg, $additional_headers);
  26.  
  27.    $required_fields = array("name" => "You forgot to add a name, retard", "address" => "Tell me where you live");
  28.  
  29.    $errorString = "you made the following errors:<br />";
  30.  
  31.    foreach ($required_fields as $value => $message){
  32.  
  33.       if (!isset($_POST[$value]) || (isset($_POST[$value]) && $_POST[$value])){
  34.  
  35.             $errorString.= $message."<br />";
  36.  
  37.          }
  38.  
  39.    }
  40.  
  41.    mail($_POST['email'],'hello there','Hello '.$_POST['name'].', thank you for filling out the form ', "From: athompson@building-doctors.com");
  42.  
  43.    echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext><tr><td>";
  44.  
  45.    echo 'Hello '.$_POST['name'].', thank you for filling out the form ';
  46.  
  47.    echo "</tr></td></table>";
  48.  
  49.    echo "<body onLoad=redirect() text=#000000 link=#00FFFF vlink=#C0C0C0>";
  50.  
  51. }else{
  52.  
  53. //below is the html form abreviated
  54.  
  55. ?>
  56.  
  57. <body leftmargin="0" topmargin="0">
  58.  
  59. <table width="400"  height="246" border="0" cellpadding="0" cellspacing="0" class="biggertext">
  60.  
  61.   <tr>
  62.  
  63.     <td height="30" valign="top"><form method="POST" action="getstartedformtrial3.php">
  64.  
  65.  
  66.  
  67. <!--the form is here -->
  68.  
  69.  
  70.  
  71.  
  72.  
  73. </form></td>
  74.  
  75.   </tr>
  76.  
  77. </table>
  78.  
  79. </body>
  80.  
  81. <?
  82.  
  83. }
  84.  
  85.  
  86.  
  87. ?>


I get no parse errors.
http://www.caffeinefuelled.net/richard- ... etTest.php
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

Why don't you just call the printform function?
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i tried that link and i get a blank screen.

so you didnt get any errors at all? did the php validate the form correctly wehn u pressed submit without filin in any fields?

Code: [ Select ]
<body leftmargin="0" topmargin="0">
<table width="400" height="246" border="0" cellpadding="0" cellspacing="0" class="biggertext">
 <tr>
  <td height="30" valign="top"><form method="POST" action="getstartedformtrial3.php">

<!--the form is here -->


</form></td>
 </tr>
</table>
</body>
  1. <body leftmargin="0" topmargin="0">
  2. <table width="400" height="246" border="0" cellpadding="0" cellspacing="0" class="biggertext">
  3.  <tr>
  4.   <td height="30" valign="top"><form method="POST" action="getstartedformtrial3.php">
  5. <!--the form is here -->
  6. </form></td>
  7.  </tr>
  8. </table>
  9. </body>


this is the source of the page from the link you sent
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 34 posts
  • Users browsing this forum: No registered users and 65 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.