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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.