Build Your Own DatabaseDriven Website Using PHP amp;amp; MySQL [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Build Your Own DatabaseDriven Website Using PHP amp;amp; MySQL [Electronic resources] - نسخه متنی

Kevin Yank

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








Adding Authors

Next
comes newauthor.php, which allows administrators to add
new authors to the database. Again, this is just like adding new jokes, which
we tackled in "Publishing MySQL Data on the Web".

<!-- newauthor.php -->
<html>
<head>
<title> Add New Author </title>
</head>
<body>
<?php
if (isset($_POST['submit'])):
// A new author has been entered
// using the form below.
$dbcnx = mysql_connect('localhost', 'root', 'mypasswd');
mysql_select_db('jokes');
$name = $_POST['name'];
$email = $_POST['email'];
$sql = "INSERT INTO Authors SET
Name='$name',
EMail='$email'";
if (@mysql_query($sql)) {
echo('<p>New author added</p>');
} else {
echo('<p>Error adding new author: ' .
mysql_error() . '</p>');
}
?>
<p><a href="'PHP_SELF']?>">Add another Author</a></p>
<p><a href=">Return to Authors list</a></p>
<?php
else: // Allow the user to enter a new author
?>
<form action="'PHP_SELF']?>" method="post">
<p>Enter the new author:<br />
Name: <input type="text" name="name" size="20" maxlength="255"
/><br />
Email: <input type="text" name="email" size="20" maxlength="255"
/><br />
<input type="submit" name="submit" value="SUBMIT" /></p>
</form>
<?php endif; ?>
</body>
</html>

/ 190