Jump to content

Form problem


elflacodepr

Recommended Posts

Hello all, my problem are in order so we can solve on at the time  :)

 

 

1. My problem is after i fill a contact form, it says the file cannot be included, I've tried using the long format (C:\...  so on) but nothing gets solved.

 

2. I don't use mysql-real-escape-string is this script as it is for personal use, but when I use mysql-real-escape-string, an error shows saying mysql-real-escape-string cannot be defined or so, I can't remember right now.

 

3. I have declared an else statement in case the form isn't filled up right, but it appears everytime i reload the page with the forms to fill.

 

 

I hope I haven't blew your head with the explanation

 

 

 

 

Here's the script:

<?php

//Get info for DB
$name = $_POST['name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$contact_group = $_POST['contact_group'];
$interests = $_POST['interests'];
$extra_info = $_POST['extra_info'];


if(isset($_POST['save'])) {
//Now write it to DB
include 'library/config.php';
include 'library/open.php';


//Query
$sql = "INSERT INTO address_book (name, last_name, phone, email, contact_group, interests, extra_info, date_added)
		VALUES ('$name', '$last_name', '$phone', '$email', '$contact_group','$interests', '$extra_info', NOW())" or die(mysql_error()); 
$result = mysql_query($sql) or die(mysql_error());


include 'library/closedb.php';

//Everything has gone right...
echo "Contact has been added!<a href=\"contact_add.php\"> Add more contacts</a> ";

} else {

//If an error has occured...
echo "You didn't provide the correct information <a href=\"contact_add.php\"> Go back!</a>";
}

?>

<html>
<body>
<form method="post">
  		<table width="700" border="0" cellpadding="2" cellspacing="1" align="center">
  			 	<tr> 
   			  	 <td width="100">Name</td>
    			 	 <td><input name="name" type="text"></td>
  			 	 </tr>
  				<tr>
				<td width="100">Last Name</td>
					<td><input name="last_name" type="text"></td>
			</tr>		
			<tr> 
   			  	 <td width="100">Phone Number</td>
    			 	 <td><input name="phone" type="text"></td>
  			 	 </tr>
  				<tr>
   			  	 <td width="100">Email</td>
    			 	 <td><input name="email" type="text"></td>
  			 	 </tr>
  				<tr>
   			  	 <td width="100">Group</td>
				<select name="contact_group">
					<option value="friends">Friends</option>
					<option value="family">Family</option>
					<option value="brothers">Brothers</option>
				</select>
  			 	 </tr>
  				<tr>
   			  	 <td width="100">Interests</td>
    			 	 <td><input name="interests" type="text"></td>
  			 	 </tr>
  				<tr>
  				<tr>
   			  	 <td width="100">Extra Info</td>
    			 	 <td><input name="extra_info" type="text"></td>
  			 	 </tr>
  				<tr>
   					<td colspan="2" align="center"><input name="save" type="submit" value="Add!"></td>
  				</tr>
  		</table>
</form>
</body>
</html>

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

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.