Jump to content

need help.. form


zelllibin

Recommended Posts

HI. i have a script below. it seems that there is some error. k anyone help me????

 

Fatal error: Function name must be a string in C:\wamp\www\php_project\final\member\addpage.php on line 31

 

<?php
// If our form has NOT been submitted....
if (!isset($_POST['submitted'])) {
?>	 
  <h3>Add Your Site</h3>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">   
<p><b>Name :</b> <input type="text" name="name" size="25" maxlength="40" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p>
    
    <p><b>Site URL :</b> <input type="text" name="url" size="25" maxlength="60" value="<?php if (isset($_POST['url'])) echo $_POST['url']; ?>" /></p>
    <p><b>Description :</b><br />
      .	    
  <textarea name="description" rows="5" cols="40"><?php if(isset($_POST['description'])) echo $_POST['description']; ?></textarea></p>
    <p><div align="center"><input type="submit" name="submit" value="Add Site" /></div>
    <input type="hidden" name="submitted" value="TRUE" />
</form>

<?php
}
else {
// If the form HAS been submitted, continue.
  
// Connect to your database
require_once('../mysql_connect.php'); 

if (empty($_POST['name'])) {
echo '<font color="red">Please enter in a name for your site.</font><br />';
$n = FALSE;
} else {
$name = $_POST['name'];
$query = "SELECT id, name FROM websites WHERE name = '$name'";
$result = mysql_query($query) OR die($mysql_error());
$num = mysql_num_rows($result);
}

if (empty($_POST['url'])) {
echo '<font color="red">Please enter in a URL for your site.</font><br />';
$u = FALSE;
} else {
$u = mysql_real_escape_string($_POST['url']);
}


if (empty($_POST['description'])) {
echo '<font color="red">Please enter in a description for your site.</font><br />';
$d = FALSE;
} else {
$d = mysql_real_escape_string($_POST['description']);
} 


if ($n && $u && $d) {
$query = "INSERT INTO websites (name, url, description, password) VALUES ('$n', '$u', '$d', SHA('$p'))";
$result = mysql_query($query) OR die(mysql_error()); 

if ($result) {
echo '<h3>Site Added!</h3>
<p>Your site has been added into your database, you may now take the code below and add it to your site so people can start voting!</p>';
      }
  }  
$query = "SELECT id, name FROM websites WHERE name = '$n'";
$result = mysql_query($query) OR die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

}
?>

Link to comment
https://forums.phpfreaks.com/topic/122395-need-help-form/
Share on other sites

  • 2 weeks later...

You are probably getting a fatal parse or fatal runtime error.

 

When learning php, developing php code, or debugging php code, you should have error_reporting set to E_ALL and display_errors set to ON in your php.ini file to get php to help you (stop and start your web server to get any changes made to php.ini to take effect.)

Link to comment
https://forums.phpfreaks.com/topic/122395-need-help-form/#findComment-640412
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.