Jump to content

phppatron

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phppatron's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I finally got my form to work, inasmuch as it takes the information and inserts it into my database table. I still need to learn a few more things, but taking the two most simple ones, I need to 1. display back to the person what they entered (I presume this would be on a new page) and 2. clear the form (at least, on my own same system the form apparently continues to hold the last entered data I'm wondering if this has to do with changing the form's beginning <?php echo($_SERVER['PHP_SELF']); ?> or not... ? (among other things) I know I need to learn how to validate and other things, but I won't go into that in this topic. Current code is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <?php $street = $_POST["street"]; $city = $_POST["city"]; $stateabbr = $_POST["stateabbr"]; $zipcode = $_POST["zipcode"]; ?> <?php $connection = mysql_connect("localhost", "user", "password"); if (!$connection){ die("Could not connect to the database: <br/>" . mysql_error()); } $db_select = mysql_select_db("database name"); if (!$db_select) { die ("could not select the database: <br />". mysql_error()); } ?> <?php $query = mysql_query ("INSERT INTO location (street, city, stateabbr, zipcode) VALUES ('$street','$city','$stateabbr','$zipcode')"); if (!empty($street)&& !empty($city) && !empty($stateabbr) && !empty($zipcode)){ $query; } ?> <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post"> <label> Street: <input type="text" name="street" value="<?php echo $street; ?>"/> </label> <label> City: <input type="text" name="city" value="<?php echo $city; ?>" /> </label> <label> State Abbrev: <input type="text" name="stateabbr" value="<?php echo $stateabbr; ?> "/> </label> <label> Zip Code: <input type="text" name="zipcode" value="<?php echo $zipcode; ?>" /> </label> <input type="submit" value="Submit" /> </form> </body> </html>
  2. ok - thanks everyone.. just proves what a newbie I am I appreciate the answers.
  3. My question is: If I delete rows in my database via phpadmin, it remembers which row ID had previously been used, so the remaining records are 1, 3, 4, 5, 8 and the rows I deleted (2, 6, 7) no longer exist. Is there some means of having the database forget the dropped records, so the numbering is sequential?
  4. thank you to all, with your help I was able to get it working -
  5. My file is a learning exercise. It has a simple form, and it uses the inserted data and is supposed to add the data to my simple database. It seems to be collecting the data (at least, if I echo the gathered data it shows properly) - so I don't know why the data is not uploaded. I understand it could be several things - but I don't know where to begin checking. I'm not getting any errors. Here is my file: (I removed the actual user and password and the database name substituted placeholders here) more info: the table has the fields in the form plus one more - ID (set to autoincrement) If nothing is wrong here, where should I begin to look?? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <?php $street = $_POST["street"]; $city = $_POST["city"]; $stateabbr = $_POST["stateabbr"]; $zipcode = $_POST["zipcode"]; ?> <?php $connection = mysql_connect("localhost", "user", "password"); if (!$connection){ die("Could not connect to the database: <br/>" . mysql_error()); } $db_select = mysql_select_db("databasename"); if (!$db_select) { die ("could not select the database: <br />". mysql_error()); } ?> <?php if (!empty($street)&& !empty($city) && !empty($stateabbr) && !empty($zipcode)){ $query="INSERT INTO 'table' VALUES ('$_POST[street]','$_POST[city]','$_POST[stateabbr]',' $_POST[zipcode])"; $result = mysql_query($query); } echo $query; ?> <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post"> <label> Street: <input type="text" name="street" value="<?php echo $street; ?>"/> </label> <label> City: <input type="text" name="city" value="<?php echo $city; ?>" /> </label> <label> State Abbrev: <input type="text" name="stateabbr" value="<?php echo $stateabbr; ?> "/> </label> <label> Zip Code: <input type="text" name="zipcode" value="<?php echo $zipcode; ?>" /> </label> <input type="submit" value="Submit" /> </form> </body> </html>
  6. hello - I need help with the message templates in phplist.  It was installed on my hosting server using Fantastico. my site is updated with a new CSS file.  The site also uses  1) PMM which is a menu system that uses a .js file and 2) nifty corner cube that also uses a .js. I'm willing to dispense with the nifty corner cube, but I'd like to incorporate the menu.  Right now, the latest try I got the menu to work, but only "sort of".  The spaces between the sub menus are giant (even though the code I included has a "fix" for IE7). I realize a lot of this is 3rd party mixed together, but I need something that looks like it comes from my site to work for a newsletter/message. Im still unclear what should or should not be included in this template (I see that I don't need to use the opening and closing <html> tags.  I have a different template that was successful, and uses an external CSS file, but I can't seem to make this one work.  I suppose it's the .js script(s).  ANyone? Pleeez?  If you are efficient in this area, please help.
×
×
  • 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.