Jump to content

another php form problem


BrotherBear

Recommended Posts

hi all !

 

yesterday I couldn't put the error where I wanted now I can but now it show the error always everytime I press the send button even if the spaces are filled here's the code of the PHP and HTML

 


<?php
$con = mysql_connect("mysql1.100ws.com","johncoda_downloa","121212");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$Name = $_POST['Name']; 
$Age = $_POST['Age']; 
$Email = $_POST['Email']; 
$Comments = $_POST['Comments']; 
if
($Name==1)
  include ("processing.php");
if
($Name==0)
  $error = "Please fill the spaces completely";
  include ("contactus.html");
  exit();
mysql_select_db("johncoda_downloa", $con);


$sql = mysql_query("INSERT INTO Customers (Name, Age,  
        Email, Comments) 
        VALUES('$Name', '$Age', '$Email',  
        '$Comments')")  
        or die (mysql_error()); 
?>
<html>
<head>
<meta http-equiv="Refresh"
content="5;url=http://johncoda.freestarthost.com/thankyou.html">
</head>
<body>
</body>
</html>

 

form script

 

   <form action='processing.php' method='post'>
  <div class='name'>*Name:</div>
  <div class='namebox'><input type='text' name='Name' style='font-family:monotype corsiva; font-size:15px;' /><br><?"$error"?></div>
  <div class='age'>*Age:</div>
  <div class='agebox'><input type='text' name='Age' style='font-family:monotype corsiva; font-size:15px;' /><br></div>
  <div class='email'>*Email:</div>
  <div class='emailbox'><input type='text' name='Email' style='font-family:monotype corsiva; font-size:15px;' /><br></div>
  
  <div class='commentss'>*Comments:</div>
  <div class='commentssbox'><textarea name='Comments'>Write Your Message</textarea></div>
  <div class='submit'><input type='submit' value='Send!' /></div>
  </form>

 

please help me, I want the rror to appear when necessary and the form to upload when everything's right

 

BB

Link to comment
https://forums.phpfreaks.com/topic/44954-another-php-form-problem/
Share on other sites

Which error do you always get?

 

I am not seeing how this would really work though:

Since the name is probably never equal to "1".. probably something like "joe".

 

<?php if
($Name==1)
  include ("processing.php");
if
($Name==0)
  $error = "Please fill the spaces completely";
  include ("contactus.html");
  exit(); ?>

 

You may try:

 

<?php if (!empty($Name)) {
include ("processing.php");
}
else {
  $error = "Please fill the spaces completely";
  include ("contactus.html");
  exit();
} ?>

 

You are only checking the name though.. so the rest could be blank and you should filter the variables.

the error that I need to fill all spaces and this error appears even if I fill the space here's the code of the error

 

if
($Name==0)
  $error = "Please fill the spaces completely";
  include ("contactus.html");
  exit();
mysql_select_db("johncoda_downloa", $con);

 

BB

did not work!!!

 

now appears 500 internal server error

 

the thing is that I want to make sure all spaces are filled so I puuted the error code above so that when one space wasn't filled the error appears and works the things is that this error appears even if you fill everything and doesn't continiue to upload the information

 

BB

I am now confused in how you coded your script.

 

You are already submitting to processing.php and then if the name field is filled in.. you are trying to include it processing.php again ??? That explains your 500 server error. It will never happen, it won't ever exit.

 

<form action='processing.php' method='post'>
include ("processing.php");

 

What else does processing.php do? You need to fix your validation code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.