I have 2 files Signup.php and signup_insert.php I have shown the code used in both. No data is being entered but no error message also! Please help.
Signup.php Code is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<div class="signup-right" style="width:898px;float:right;">
<h2> Sign Up Form</h2>
<form action="signup_insert.php" method="post" id="insert" name="signup" onsubmit="return validateForm();" >
<table align="center">
<tr class=""> <td>Company Name</td> <td> <input type="text" size="50" name="COMPANY_NAME" id="COMPANY_NAME" /> </td> </tr>
<tr class=""> <td>Street</td> <td> <input type="text" size="50" name="COMPANY_STREET" id="COMPANY_STREET" /> </td> </tr>
<tr class=""> <td>City</td><td> <input type="text" size="50" name="COMPANY_CITY" id="COMPANY_CITY" /> </td> </tr>
<tr class=""> <td>Zip</td><td> <input type="text" size="50" name="COMPANY_ZIP" id="COMPANY_ZIP" /> </td> </tr>
<tr class=""> <td>State</td><td><select name="COMPANY_STATE" id="COMPANY_STATE"> <option>Oregon</option> </select>
</td> </tr> <tr class=""> <td>Country</td> <td> <input type="text" size="50" name="COMPANY_COUNTRY" id="COMPANY_COUNTRY" value="United States of America"/> </td> </tr>
<tr class=""> <td>Logo</td><td> <input type="text" size="50" name="COMPANY_LOGO" id="COMPANY_LOGO"/> </td> </tr>
<tr class=""> <td>Phone</td><td> <input type="text" size="50" name="COMPANY_PHONE" id="COMPANY_PHONE"/> </td> </tr>
<tr class="">
<td>E-mail</td> <td> <input type="text" size="50" name="COMPANY_EMAIL" id="COMPANY_EMAIL"/> </td>
</tr>
<tr> <td><label for="password">Password*</label></td> <td><input type="password" size="40" name="password" id="password" /> <font color="red"> (Minimum 8 characters)</font></td>
</tr>
<tr class=""> <td> <label for="securityq">Security Question</label> </td> <td> <select name="securityq" id="securityq"><option>What is your mother's maiden name ?</option></select></td> </tr>
<tr class=""><td> <label for="securitya">Security Answer*</label> </td> <td> <input type="text" size="40" name="securitya" id="securitya" /> </td></tr>
<tr> <td colspan="2" id="sub"> <input type="submit" name="submitb" value="Submit" id="submitb" class="contact-btn"/> <input type="reset" name="resetb" value="Reset" class="contact-btn"/> </td> </tr>
</table>
</form>
</div>
</body>
</html>
Singnup_insert Code is:
<?php
require_once 'config.php';
require_once 'testemail.php';
//ini_set('display_errors', 1); error_reporting(~0);
function error($msg) {
global $message;
$message = $msg;
include "signup.php";"database.php";
die();
}
function error2($msg) {
error("<font color=\"red\"><b><i>$msg</i></b></font>");
}
function esc($data) {
return mysql_real_escape_string($data);
}
function rstr() {
$s = '';
for ($i=0;$i<5;$i++) $s .= chr(rand(ord('a'), ord('z')));
return $s;
}
function getesc($varname) {
global $$varname;
$$varname = isset($_POST[$varname]) ? esc($_POST[$varname]) : "";
return $$varname;
}
//Get data in local variable
getesc('COMPANY_NAME');
getesc('COMPANY_STREET');
getesc('COMPANY_CITY');
getesc('COMPANY_ZIP');
getesc('COMPANY_STATE');
getesc('COMPANY_COUNTRY');
getesc('COMPANY_PHONE');
getesc('COMPANY_EMAIL');
getesc('password');
getesc('rpassword');
getesc('securityq');
getesc('securitya');
// check for null values
if ($COMPANY_NAME=="") error2("Please enter Company name");
if ($COMPANY_STREET=="") error2("Please enter Street name");
if ($COMPANY_CITY=="") error2("Please enter City");
if ($COMPANY_ZIP=="") error2("Please enter Zip");
if ($COMPANY_COUNTRY=="") error2("Please enter Country");
if ($COMPANY_PHONE=="") error2("Please enter Phone");
if ($COMPANY_EMAIL=="") error2("Please enter Email");
$COMPANY_NAME = $COMPANY_NAME;
$COMPANY_STREET = $COMPANY_STREET;
$COMPANY_CITY = $COMPANY_CITY;
$COMPANY_ZIP = $COMPANY_ZIP;
$COMPANY_COUNTRY = $COMPANY_COUNTRY;
$COMPANY_PHONE = $COMPANY_PHONE;
if (""!=($testresult = test_email(isset($_POST['COMPANY_EMAIL']) ? $_POST['COMPANY_EMAIL'] : "" )))
error2($testresult);
//if ($remail=="" ) error2("Please confirm Email");
//if ($remail!=$email) error2("Email's don't match. Please check email and re-enter");
if ($password=="" or strlen($password)<8) error2("Password does not meet criteria. Please check and enter Password");
if ((!preg_match('/[a-z]/', $password)) ||
(!preg_match('/[A-Z]/', $password)) ||
(!preg_match('/[0-9]/', $password)))
error2("The password must contain at least one digit, one small character, and one big character!");
if ($rpassword=="") error2("Please confirm Password");
//if ($rpassword!=$password) error2("Password's don't match. Please check password and re-enter");
if ($securitya=="") error2("Please enter answer to Security question");
$vercode = rstr();
$COMPANY_LOGO = htmlspecialchars($data['COMPANY_LOGO']);
$current_time = "_".time();
if ((($_FILES["file"]["type"] == "image/gif") ||($_FILES["file"]["type"] == "image/png") ||($_FILES["file"]["type"] == "image/jpeg") ||($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 716800))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "<h2>"."Success! Picture Uploaded."."</h2>"."<br />";
echo "Upload: " . $_FILES["file"]["name"] .$current_time. "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"].$current_time);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"].$current_time;
$pic = "upload/" . $_FILES["file"]["name"].$current_time;
}
}
else
{
echo "Invalid file. <br /> Please ensure file extension is gif, jpeg or png and file size <= 700KB. Thanks for your understanding and co-operation.";
}
mysql_query("update COMPANY set `COMPANY_LOGO`='$COMPANY_LOGO' where username='$user'") or die(mysql_error());
// insert local variables into database
$query = "INSERT INTO COMPANY " .
"(COMPANY_NAME, COMPANY_STREET, COMPANY_CITY, COMPANY_ZIP, COMPANY_STATE, COMPANY_COUNTRY, COMPANY_LOGO, COMPANY_PHONE, COMPANY_EMAIL, securityq,
securitya) VALUES " .
"('$COMPANY_NAME','$COMPANY_STREET','$COMPANY_CITY','$COMPANY_ZIP','$COMPANY_STATE','$COMPANY_COUNTRY','$COMPANY_LOGO','$COMPANY_PHONE','$COMPANY_EMAIL'," .
"'$password','$securityq','$securitya', 0, '$vercode');";
if (mysql_query($query)===FALSE) error2("Error inserting into the database.");
//define the receiver of the email
$to = $email;
// define subject of the email
$subject = 'Confirmation to join the LineSmash family!';
//define the message to be sent and the link within the message. Each line should be separated with \r\n
$link="http://linesmash.com/signupv.php?code=$vercode";
$message = <<<EOM
Hello $COMPANY_NAME,
Text
Your confirmation code: $vercode
EOM;
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From:support@linesmash";
if (mail($to,$subject,str_replace("\n", "\r\n", $message),$headers)===FALSE)
error2("Error - Could not send confirmation email!"); ?>
<?php
$name = '';
if (isset($_SESSION['user'])){ $user=mysql_real_escape_string(trim($_SESSION['user']));
$res = mysql_query("SELECT COMPANY_NAME,COMPANY_STATE, COMPANY_CITY FROM COMPANY WHERE username = '$user'") or die (mysql_error());
$data = mysql_fetch_assoc($res);
$name .= htmlspecialchars($data['COMPANY_NAME']); ?>
<ul class="current-nav">
<li class="current-nav-item left">
<div>
<!--<script type="text/javascript" src="MPBackLinks.js"></script>-->
<span><a hef="index.php">home</a> > sign up </span> </div>
</li>
<li class="current-nav-item right">
<span>Welcome <?php echo $name; ?></span>
</li>
</ul>
<?php } else { ?>
<ul class="current-nav">
<li class="current-nav-item left">
<div>
<!--<script type="text/javascript" src="MPBackLinks.js"></script>-->
<span><a hef="index.php">home</a> > sign up </span>
</div>
</li>
</ul>
<?php
}
?>
</center>
<br/> <font color=blue> <center><b><i>Congratulations <?php echo $COMPANY_NAME; ?>!</i></b> <br /><br /> Text <br /><br /> Text</center> <br /><br/>
<center><p> <a href="database.php" class="sign-up-btn">Add another entry</a> </p> </center> </font>
</div> </div> </body></html>
}