Jump to content


Photo

Query/ Include Question


  • Please log in to reply
2 replies to this topic

#1 Asterixx

Asterixx
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 March 2006 - 01:51 PM

PHP beginner here...

<?php
include("config.php");

  if($submit)
  {
include('post.txt');
if(!$contact){  //this means If the title is really empty.
echo "Error: Contact is a required field. Please fill it.";
exit(); //exit the script and don't do anything else.
 }

$result = mysql_query("INSERT INTO AL_BVA (contact, time, phone, address, city, state, zip, email, website, notes)
VALUES ('$contact',NOW(),'$phone','$address','$city','$state','$zip','$email','$website','$notes')",$connect);
  
echo "Contact added";
          echo "<meta http-equiv=Refresh content=4;url=bvaindex.php>";
  }

else
  {

      ?>
<?
include('form.txt');
?>      
      <?
  }
  
  mysql_close($connect);

?>
FORM.TXT

<br>
      <h3>::Add Contact::</h3>

      <form method="post" action="<?php echo $PHP_SELF ?>">

     Contact: <input name="contact" size="40" maxlength="50">
      <br>
     Phone: <input name="phone"  size="20" maxlength="20">
      <br>
      Address: <input name="address"  size="40" maxlength="100">
      <br>
City: <input name="city"  size="40" maxlength="50">
      <br>
State: <input name="state"  size="4" maxlength="4">
      <br>
 Zip: <input name="zip"  size="20" maxlength="20">
      <br>
      Email: <input name="email"  size="40" maxlength="50">
      <br>
     Website: <input name="website"  size="40" maxlength="50">
  <br>
     Notes: <textarea name="notes" rows="7" cols="30"></textarea>
<br>
      <input type="submit" name="submit" value="Add Contact">
      </form>
POST.TXT

<?
      $contact = $_POST['contact'];
      $phone = $_POST['phone'];
      $address = $_POST['address'];
  $city = $_POST['city'];
  $state = $_POST['state'];
  $zip = $_POST['zip'];
      $email = $_POST['email'];    
      $website = $_POST['website'];
      $notes = $_POST['notes'];
?>

I'm trying to do what I did with these 2 .txt files with the data after AL_BVA and VALUES, so I can edit it from an external file. I can currently edit these 2 .txt files and the form works in over 100 pages.

I've tried stuff like what follows but that gives me a parsing error.

$result = mysql_query("INSERT INTO AL_BVA (include'data.txt')
                       VALUES (include'values.txt')",$connect);
I desperately need this to work. :)

Thanks in advance!

P.S.: the server runs PHP4+

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 24 March 2006 - 02:08 PM

I don't know what you're trying to do. You can't include the contents of a text file like that in the middle of a string. It doesn't work like that.

Info: PHP Manual


#3 Asterixx

Asterixx
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 March 2006 - 02:19 PM

Thanks! Finally someone giving me a straight answer.

If I can't use Include, what can I use? Is it not possible?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users