Jump to content

Recommended Posts

This is my html form.

 

  <table clas="rink_form">

  <form method="post" action="form_survey.php">

    <tr>

      <td>

        Rink Name:  <input name="RinkName" type="text" class="form_text"> 

        Rink Address: <input name="RinkAdress" type="text" class="form_text">

      </td> 

    </tr>

   

    <td>Enter code below:</td>

  <td><img src="secimg.php"></td>

</tr>

<tr>

<td> </td>

  <td><input type="text" name="Spam Code" size="8" /></td>

  </tr>

 

  <tr>

    <td colspan="2" align="center"><input type="submit" value="Submit Form">

      </td>

  </tr>

 

  </form>

  </table> 

 

  And heres my php script mail

 

  <?php

function checkEmpty($names, $data) {

$n = count($names);

$emptys = array();

for ($i = 0; $i < $n; $i++) {

if (empty($data[$names[$i]])) $emptys[] = $names[$i];

}

return $emptys;

}

 

function createUList($arr) {

$n = count($arr);

echo '<ul>';

for ($i = 0; $i < $n; $i++)

  echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

echo '</ul>';

}

 

// needed so we can retrieve security code

session_start();

 

//This command imports the values from contact.php. Please do not touch.

@import_request_variables("gpc");

 

//The email address the message will be sent to

$youremail = "mymail@yahoo.com";

 

//The subject of the email you will receive;

$subject = "Ice Rink Supply - Survey Assessment Form";

 

//The page your visitor will be redirected to.

$redirect = "http://www.google.com";

 

//Time until the page redirects your visitor (seconds)

$secs = "5";

 

//This takes all of the information from the form and sorts it out. Please leave as is.

 

$name= $FONT_SIZE;

 

$FONT_SIZE=14;

$thetext=$thetext."<html><body>\n";

foreach ($_POST as $name => $value)

{

$name = str_replace('_',' ',$name);

$thetext=$thetext."$name : <b>$value</b>\n<br/>";

}

$thetext=$thetext."</body></html>";

?>

 

<html>

    <head> </head>

  <body>

      <?

 

//Checks to see if the name field is empty. You can delete or add fields as needed.

 

// fill $infoToCheck with info that NEEDS to be filled. Spam_Code is always needed here

$infoToCheck = array("RinkAdress");

$emptyFlds = checkEmpty($infoToCheck,$_POST);

$validSecurityCode = md5($_POST['Spam_Code']) == $_SESSION['key'];

// to make displaying invalid spam code msg easier

if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";

$noEmptyFlds = count($emptyFlds) == 0;

 

if ($noEmptyFlds && $validSecurityCode)

{

unset($_SESSION['key']); // prevent multiple send

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* <--  the ff. lines are optional

$headers .= "From: ".$myname."

<".$myemail.">\r\n";

$headers .= "To:  <".$email.">\r\n";

$headers .= "Reply-To: ".$myname."

<$myemail>\r\n";

$headers .= "X-Priority: 1\r\n";

$headers .= "X-MSMail-Priority: High\r\n";

$headers .= "X-Mailer: Just My Server";

*/ 

  $name = stripslashes($name);

  $message = stripslashes($message);

//This is where the email is sent using your values from above.

  mail($youremail,$subject,$thetext,$headers);

?>

 

<meta http-equiv="refresh" content="<?=$secs;?>;URL=<?=$redirect;?>">

<font size="+1">

<p align="center" class="prod_h1" style="color:#FFFFFF" >Thank you, we have recieved your Assessment Form.</p>

<p class="rink_form" align="center" style="color:#FFFFFF">

You are now being redirected to our <a href="<?=$redirect;?>" style="color:#00CCFF">homepage</a>.

</font>

<?

}

else

{

?>

<font size="+1">

We require the ff. in order to reply to your message: <br/> </font>

<?php

if (!$noEmptyFlds) createUList($emptyFlds);

?>

<center>

<font color="#FFFFFF" size="+1">

Please click <a href="javascript:history.back(1);" style="color:#00CCFF">here</a> or your browsers back button to try again.

</font> <br/> <br/>

</center>

<?

}

 

?>

 

  </body>

</html>

 

 

  I wonder why isnt working?

My other form that i made with a same codes, it all works.  ???

 

 

Link to comment
https://forums.phpfreaks.com/topic/157761-my-form-arent-working-well/
Share on other sites

  Once i fill up a form it not will read & test if the form was been fill in up

  suppose to be once it corrects it will send through mail php script.

  Why it does not read the name="RinkName" this

  Rink Name:  <input name="RinkName" type="text" class="form_text"> 

 

<i> Which is my script </I>

 

 

  <?php

function checkEmpty($names, $data) {

$n = count($names);

$emptys = array();

for ($i = 0; $i < $n; $i++) {

if (empty($data[$names[$i]])) $emptys[] = $names[$i];

}

return $emptys;

}

 

function createUList($arr) {

$n = count($arr);

echo '<ul>';

for ($i = 0; $i < $n; $i++)

  echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

echo '</ul>';

}

 

// needed so we can retrieve security code

session_start();

 

//This command imports the values from contact.php. Please do not touch.

@import_request_variables("gpc");

 

//The email address the message will be sent to

$youremail = "mymail@yahoo.com";

 

//The subject of the email you will receive;

$subject = "Ice Rink Supply - Survey Assessment Form";

 

//The page your visitor will be redirected to.

$redirect = "http://www.google.com";

 

//Time until the page redirects your visitor (seconds)

$secs = "5";

 

//This takes all of the information from the form and sorts it out. Please leave as is.

 

$name= $FONT_SIZE;

 

$FONT_SIZE=14;

$thetext=$thetext."<html><body>\n";

foreach ($_POST as $name => $value)

{

$name = str_replace('_',' ',$name);

$thetext=$thetext."$name : <b>$value</b>\n<br/>";

}

$thetext=$thetext."</body></html>";

?>

 

 

  <?php

    infoToCheck = array("RinkName");

   

    if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";

$noEmptyFlds = count($emptyFlds) == 0;

 

if ($noEmptyFlds && $validSecurityCode)

{

unset($_SESSION['key']); // prevent multiple send

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

 

$name = stripslashes($name);

  $message = stripslashes($message);

//This is where the email is sent using your values from above.

  mail($youremail,$subject,$thetext,$headers);

?>

 

 

  It suppose to send a value from a text box just like an email form too.

  Basically it will not test if the textbox was fill in.

 

  Once i fill up a form it not will read & test if the form was been fill in up

  suppose to be once it corrects it will send through mail php script.

  Why it does not read the name="RinkName" this

  Rink Name:  <input name="RinkName" type="text" class="form_text"> 

 

Which is my script

 

 

  <?php

function checkEmpty($names, $data) {

$n = count($names);

$emptys = array();

for ($i = 0; $i < $n; $i++) {

if (empty($data[$names[$i]])) $emptys[] = $names[$i];

}

return $emptys;

}

 

function createUList($arr) {

$n = count($arr);

echo '<ul>';

for ($i = 0; $i < $n; $i++)

  echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

echo '</ul>';

}

 

// needed so we can retrieve security code

session_start();

 

//This command imports the values from contact.php. Please do not touch.

@import_request_variables("gpc");

 

//The email address the message will be sent to

$youremail = "mymail@yahoo.com";

 

//The subject of the email you will receive;

$subject = "Ice Rink Supply - Survey Assessment Form";

 

//The page your visitor will be redirected to.

$redirect = "http://www.google.com";

 

//Time until the page redirects your visitor (seconds)

$secs = "5";

 

//This takes all of the information from the form and sorts it out. Please leave as is.

 

$name= $FONT_SIZE;

 

$FONT_SIZE=14;

$thetext=$thetext."<html><body>\n";

foreach ($_POST as $name => $value)

{

$name = str_replace('_',' ',$name);

$thetext=$thetext."$name : <b>$value</b>\n<br/>";

}

$thetext=$thetext."</body></html>";

?>

 

 

  <?php

    infoToCheck = array("RinkName");

   

    if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";

$noEmptyFlds = count($emptyFlds) == 0;

 

if ($noEmptyFlds && $validSecurityCode)

{

unset($_SESSION['key']); // prevent multiple send

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

 

$name = stripslashes($name);

  $message = stripslashes($message);

//This is where the email is sent using your values from above.

  mail($youremail,$subject,$thetext,$headers);

?>

 

 

  It suppose to send a value from a text box just like an email form too.

  Basically it will not test if the textbox was fill in.

 

Please click on the Forum DO NOTs link in my sig and read #6 and #13. People here are donating their time so your urgency is not any of our concern. And I believe Maq asked you to use


tags, not

tags.

 

Believe it or not, following these formats will help you get help faster.

Ok im sory  :-[

 

This is my html form.

    <table clas="rink_form">
   <form method="post" action="form_survey.php">
     <tr>
      <td>
         Rink Name:  <input name="RinkName" type="text" class="form_text"> 
         Rink Address: <input name="RinkAdress" type="text" class="form_text">
      </td> 
     </tr>
     
    <td>Enter code below:</td>
   <td><img src="secimg.php"></td>
   </tr>
   <tr>
    <td> </td>
   <td><input type="text" name="Spam Code" size="8" /></td>
  </tr>

   <tr>
     <td colspan="2" align="center"><input type="submit" value="Submit Form">
       </td>
   </tr>
   
   </form>
   </table>   

   

  And my script

 

     <?php
function checkEmpty($names, $data) {
   $n = count($names);
   $emptys = array();
   for ($i = 0; $i < $n; $i++) {
      if (empty($data[$names[$i]])) $emptys[] = $names[$i];
   }
   return $emptys;
}

function createUList($arr) {
$n = count($arr);
echo '<ul>';
for ($i = 0; $i < $n; $i++)
  echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";
echo '</ul>';
}

// needed so we can retrieve security code
session_start();

//This command imports the values from contact.php. Please do not touch.
@import_request_variables("gpc");

//The email address the message will be sent to
$youremail = "mymail@yahoo.com";

//The subject of the email you will receive;
$subject = "Ice Rink Supply - Survey Assessment Form";

//The page your visitor will be redirected to.
$redirect = "http://www.google.com";

//Time until the page redirects your visitor (seconds)
$secs = "5";

//This takes all of the information from the form and sorts it out. Please leave as is.

$name= $FONT_SIZE;

$FONT_SIZE=14;
$thetext=$thetext."<html><body>\n";
foreach ($_POST as $name => $value)
{
$name = str_replace('_',' ',$name);
$thetext=$thetext."$name : <b>$value</b>\n<br/>";
}
$thetext=$thetext."</body></html>";
?>

<html>
    <head> </head>
   <body>
      <?php

//Checks to see if the name field is empty. You can delete or add fields as needed.

// fill $infoToCheck with info that NEEDS to be filled. Spam_Code is always needed here
$infoToCheck = array("RinkAdress");
$emptyFlds = checkEmpty($infoToCheck,$_POST);
$validSecurityCode = md5($_POST['Spam_Code']) == $_SESSION['key'];
// to make displaying invalid spam code msg easier
if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";
$noEmptyFlds = count($emptyFlds) == 0;

if ($noEmptyFlds && $validSecurityCode)
{
unset($_SESSION['key']); // prevent multiple send
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* <--  the ff. lines are optional
$headers .= "From: ".$myname."
<".$myemail.">\r\n";
$headers .= "To:  <".$email.">\r\n";
$headers .= "Reply-To: ".$myname."
<$myemail>\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";
*/ 
  $name = stripslashes($name);
  $message = stripslashes($message);
//This is where the email is sent using your values from above.
  mail($youremail,$subject,$thetext,$headers);
?>

<meta http-equiv="refresh" content="<?=$secs;?>;URL=<?=$redirect;?>">
<font size="+1">
<p align="center" class="prod_h1" style="color:#FFFFFF" >Thank you, we have recieved your Assessment Form.</p>
<p class="rink_form" align="center" style="color:#FFFFFF">
You are now being redirected to our <a href="<?=$redirect;?>" style="color:#00CCFF">homepage</a>.
</font>
<?
}
else
{
?>
<font size="+1">
We require the ff. in order to reply to your message: <br/> </font>
<?php
if (!$noEmptyFlds) createUList($emptyFlds);
?>
<center>
<font color="#FFFFFF" size="+1">
Please click <a href="javascript:history.back(1);" style="color:#00CCFF">here</a> or your browsers back button to try again.
</font> <br/> <br/>
</center>
<?
}

?>
          
   </body>
</html>
  

      :-[  Is there something that i mess up?  :-[

1. Put session_start() at the top of the script (but within php tags).

 

2.

$name= $FONT_SIZE;

$FONT_SIZE=14;

$name = $FONT_SIZE is wrong because at that point, $FONT_SIZE is not defined.

 

3.

$thetext=$thetext."<html><body>\n";

You can't assign $thetext to be $thetext + something else because $thetext is not defined up until that point.

 

4.

$infoToCheck = array("RinkAdress");
$emptyFlds = checkEmpty($infoToCheck,$_POST);

Shouldn't you add RinkName to that array $infoToCheck? Also, what's the point of those two lines after the foreach loop over $_POST about 16 lines up?

 

5.

if ($noEmptyFlds && $validSecurityCode)

I don't think you have to add && $validSecurityCode because if you have an invalid security code, $noEmptyFlds should not be true.

 

First round QA done. Back to you.

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.