--- "D. K. Wema" <[EMAIL PROTECTED]> wrote:
> I've tried to make the following script work but it
> has totally failed. After many hours of frustration, I
> kindly ask anyone who can help to save my day. The
> script is supposed to insert data into the database
> (mysql). When I enter the data and press the submit
> button, the entered data disappears but nothing gets
> to the database.
As already noted, your problem is that your script assumes that
REGISTER_GLOBALS is turned on and most servers leave it off for security
reasons. Perhaps you are using an old tutorial. REGISTER_GLOBALS takes form
and cookie inputs and makes local variables when the script runs. This
convenience comes at a price of lower security.
Another factor which may be an issue is MAGIC_QUOTES_GPC which is usually on on
most servers but is occasionally off. This feature adds backslashes for some
special characters, like quotation marks.
If your only problem is REGISTER_GLOBALS you can add this line at the top of
your program to make a quick fix:
extract($_POST);
That assumes your form is using the POST method which it is according to your
code. If you were using GET then it would be:
extract($_GET);
If MAGIC_QUOTES_GPC is off, you may need to process each value in the $_POST
array with addslashes() before you do the extract(). The extract() function
will take each key-value pair in the $_POST associative array and make it into
a local variable where the variable name is the array key and the value is the
corresponding array value.
James D. Keeline
> <?php
> include("include/dbconnect.php");
> if($submit)
> {
>
> $sql = "INSERT INTO $table (firstname, lastname,
> cpeyear, city, country, workplace, email, comments)
> VALUES
>
('$firstname','$lastname','$cpeyear','$city','$country','$workplace','$email','$comments')";
> $result = mysql_query($sql);
> echo "<br><br>Information entered into address
> book.\n";
> }
> else
> {
> ?>
>
> <form method="post" action="<?php echo $PHP_SELF?>">
> <table width="440" border="0" cellspacing="1"
> cellpadding="1">
> <tr>
> <td width="158">
> <input type="hidden" name="id" value="<?php
> echo $myrow["id"]?>">
> Firstname:</td>
> <td width="275">
> <input type="Text" name="firstname"
> size="30">
> </td>
> </tr>
> <tr>
> <td>Lastname:
> </td>
> <td>
> <input type="Text" name="lastname"
> size="30">
> </td>
> </tr>
> <tr>
> <td>CPE/KCPE Year:</td>
> <td>
> <select name="cpeyear">
> <option value="1968">1968</option>
> <option value="1969">1969</option>
> <option value="1970">1970</option>
> <option value="1971">1971</option>
> <option value="1972">1972</option>
> <option value="1973">1973</option>
> <option value="1974">1974</option>
> <option value="1975">1975</option>
> <option value="1976">1976</option>
> <option value="1977">1977</option>
> <option value="1978">1978</option>
> <option value="1979">1979</option>
> <option value="1980"
> selected>1980</option>
> <option value="1981">1981</option>
> <option value="1982">1982</option>
> <option value="1983">1983</option>
> <option value="1984">1984</option>
> <option value="1985">1985</option>
> <option value="1986">1986</option>
> <option value="1987">1987</option>
> <option value="1988">1988</option>
> <option value="1989">1989</option>
> <option value="1990">1990</option>
> <option value="1991">1991</option>
> <option value="1992">1992</option>
> <option value="1993">1993</option>
> <option value="1994">1994</option>
> <option value="1995">1995</option>
> <option value="1996">1996</option>
> <option value="1997">1997</option>
> <option value="1998">1998</option>
> <option value="1999">1999</option>
> <option value="2000">2000</option>
> <option value="2001">2001</option>
> <option value="2002">2002</option>
> <option value="2003">2003</option>
> </select>
> </td>
> </tr>
> <tr>
> <td>City:
> </td>
> <td>
> <input type="Text" name="city" size="50">
> </td>
> </tr>
> <tr>
> <td>Country:</td>
> <td>
> <input type="Text" name="country"
> size="50">
> </td>
> </tr>
> <tr>
> <td>Workplace</td>
> <td>
> <input type="Text" name="workplace"
> size="70">
> </td>
> </tr>
> <tr>
> <td>Email:
> </td>
> <td>
> <input type="Text" name="email" size="35"
> size="40">
> </td>
> </tr>
> <tr>
> <td>Any comments: </td>
> <td>
> <textarea name="comments" rows="5"
> cols="40"></textarea>
> </td>
> </tr>
> </table>
> <input type="Submit" name="submit" value="Submit
> information">
> </form>
> <?
> }
> ?>
>
>
> Thanks in advance,
> dk
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page
http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/HKFolB/TM
--------------------------------------------------------------------~->
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/