Jump to content

Archived

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

Asterixx

Query/ Include Question

Recommended Posts

PHP beginner here...

[code]<?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);

?>[/code]
FORM.TXT

[code]<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>[/code]
POST.TXT

[code]<?
      $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'];
?>[/code]

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.

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

Thanks in advance!

P.S.: the server runs PHP4+

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks! Finally someone giving me a straight answer.

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

Share this post


Link to post
Share on other sites

×

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.