TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02-17-2009, 03:27 PM   #1 (permalink)
dp2
The Visitor
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
dp2 is on a distinguished road
Default Basic php form update mysql script

I am attempting to build a php form to update my database

I can php read from but trying to put this data into a form that will update my database. Is proving difficult In this example the first part is reading ok I'm now trying to get the data into the form fields, What is happerning is the data and variables are being erased.

Any ideas where I am going wrong? Thank you

Code:
<HTML>
<HEAD>
<TITLE> The Reg Directory </TITLE>
<HEAD>
<BODY>
<?php 

$dbcnx = @mysql_connect("localhost", "username", "password");
if (!$dbcnx) {
  echo( "<P>Unable to connect to the" .
        "database server at this time.</P>" );
  exit();
}

//select which database you want to edit
mysql_select_db("aynsley_phpbb1",$dbcnx);

if (! @mysql_select_db("aynsley_phpbb1") ) {
  echo( "<P>Unable to locate the regdir " .
        "database at this time.</P>" );
  exit();
}

 // Request the text of all the business names
  $result = mysql_query(
            "SELECT BusinessName FROM regdir");
  if (!$result) {
    echo("<P>Error performing query: " .
         mysql_error() . "</P>");
    exit();
  }
//mysql_query(<query>, <connection id>);
while ($row=mysql_fetch_array($result)) {
  echo("<P>" . $row["BusinessName"] . "</P>");
}
?>
<P> Here are all the Businesses in our database: </P>
<BLOCKQUOTE>

<?php

 // Request the text of all the business names
  $result = mysql_query(
            "SELECT BusinessStreet FROM regdir");
  if (!$result) {
    echo("<P>Error performing query: " .
         mysql_error() . "</P>");
    exit();
  }

  // Display the text of each BusinessName in a paragraph
  while ( $row = mysql_fetch_array($result) ) {
  }
?>
<html>
<body>
<form method="post"action="<?php echo $PHP_SELF ?>">
<input type=text name="action" value="">
Business Name 
<input type=text name="BusinessName" value="<?PHP echo $BusinessName ?>"></br>
<input type=text name="BusinessStreet" value="<?PHP echo $BusinessStreet ?>">
<input type=submit name="submit" value="submit">
</form>
<?php
  echo("$BusinessStreet");
  

?>
</BLOCKQUOTE>
</BODY>
</HTML>
dp2 is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Contact Form Script Matt83 Script Giveaway 20 10-22-2012 10:18 AM
Part 2: Giving our Currency Conversion Script some Responsibility Wildhoney General 15 03-17-2009 01:53 PM
email fill in form help? PHP sacred_tinker Absolute Beginners 19 05-28-2008 05:58 AM
Error in connecting to MySQL via PHP EyeDentify MySQL & Databases 0 01-03-2008 01:06 PM
Uploading Files with PHP daz Absolute Beginners 3 09-30-2007 06:23 PM


All times are GMT. The time now is 11:23 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design