|
Posted by Gleep on 05/22/07 03:35
On Mon, 21 May 2007 22:21:24 -0400, Robert <lektrikpuke@_yahoo.com> wrote:
>connect.php (note: I have tried localhost)
>***************************
><?php
>$conn = mysql_connect("127.0.0.1:3306", "user_name", "password");
>mysql_select_db("dbase_name", $conn);
>?>
>**************************
>
>insert_names.php (html, to make it easier for humans)
>**************************
><HTML>
><HEAD>
><TITLE>Insert Form</TITLE>
></HEAD>
><BODY>
><FORM ACTION="insert_data.php" METHOD=POST>
><P>Advertiser: <input type=text name="adv_name" size=20><P>
>Contact: <input type=text name="cont_name"
>size=20>
>Title: <input type=text name="cont_title" size=20><P>Street:
><input type=text name="address" size=40>
>Suite:
><input type=text name="apt" size=10><P>City:
><input type=text name="city" size=20> State:
><input type=text name="state" size=5> Zip:
><input type=text name="zip" size=10><br><br>
>Notes:<P style="margin-top: 0; margin-bottom: 0">
><textarea cols="50" rows="12" name="notes"></textarea><p>
><input type=submit name="submit" value="Insert Record"></p>
></FORM>
></BODY>
></HTML>
>*************************
>
>insert_data.php (I have tried echoing output here and everything is blank)
>*************************
><?php
>include ("connect.php");
>$sql = "INSERT INTO advertiser_tbl (adv_name, address, apt, city, state,
>zip, notes) values ('$adv_name', '$address', '$apt', '$city', '$state',
>'$zip', '$notes')";
>echo $sql;
>if (mysql_query($sql, $conn)){
> echo "record added!";
>} else {
> echo "something went wrong";
>}
>?>
>
>I can get this working locally on my Windoze and Linux installations.
>When I try it on my friend's server, nothing but the defaults are put in
>to the database. All fields except those with defaults and
>autoincrement primary are blank. Any clues?
>
>Thanks.
>
>Robert
You need to get some decent books on the topic. On your local machine globals is probably turned on.
By default and most servers globals is turned off. So you need to specifie the posted values like
so..
$adv_name = $_POST['adv_name'];
$address = $_POST['address'];
$apt = $_POST['apt'];
you get the idea.
In additional to that you need to understand validation technique. To protect you db from being
attacked and to make sure people are not posting garbage. But that's another topic.
Navigation:
[Reply to this message]
|