Jump to content

Query/ Include Question


Asterixx

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