Hello all :)

I want when a user entres the requested data, the script to insert those data in the prope table depending on the choise the user does from the drop down menu.
Below is the code.

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$site_type = $_REQUEST['category_selection'];
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Web_Sites")) {
  $insertSQL = sprintf("INSERT INTO partner_sites (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['url_field'], "text"),
                       GetSQLValueString($_POST['title_field'], "text"),
                       GetSQLValueString($_POST['anchor_field'], "text"),
                       GetSQLValueString($_POST['description_field'], "text"),
                       GetSQLValueString($_POST['webmaster_nane_field'], "text"),
                       GetSQLValueString($_POST['webmaster_email_field'], "text"),
                       GetSQLValueString($_POST['category_selection'], "text"));

  mysql_select_db($database_content_conn, $content_conn);
  $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); 

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Blogs")) {
  $insertSQL = sprintf("INSERT INTO partner_sites (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['url_field'], "text"),
                       GetSQLValueString($_POST['title_field'], "text"),
                       GetSQLValueString($_POST['anchor_field'], "text"),
                       GetSQLValueString($_POST['description_field'], "text"),
                       GetSQLValueString($_POST['webmaster_nane_field'], "text"),
                       GetSQLValueString($_POST['webmaster_email_field'], "text"),
                       GetSQLValueString($_POST['category_selection'], "text"));

  mysql_select_db($database_content_conn, $content_conn);
  $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error());

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Directories")) {
  $insertSQL = sprintf("INSERT INTO partner_sites (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['url_field'], "text"),
                       GetSQLValueString($_POST['title_field'], "text"),
                       GetSQLValueString($_POST['anchor_field'], "text"),
                       GetSQLValueString($_POST['description_field'], "text"),
                       GetSQLValueString($_POST['webmaster_nane_field'], "text"),
                       GetSQLValueString($_POST['webmaster_email_field'], "text"),
                       GetSQLValueString($_POST['category_selection'], "text"));

  mysql_select_db($database_content_conn, $content_conn);
  $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error());

And below is the html code

<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="link_submission" id="link_submission">

<table width="630" border="0" align="center" cellpadding="5" cellspacing="5">
  <tr>
    <td width="76">URL:*</td>
    <td width="519"><label for="url_field"></label>
      <span id="sprytextfield1">
      <label for="url_field"></label>
      <input name="url_field" type="text" id="url_field" size="50" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
  <tr>
    <td>Anchor Text:*</td>
    <td><label for="anchor_field"><span id="sprytextfield2">
      <input type="text" name="anchor_field" id="anchor_field" />
      <span class="textfieldRequiredMsg">A value is required.</span></span></label></td>
    </tr>
  <tr>
    <td>URL Title:*</td>
    <td><label for="title_field"><span id="sprytextfield3">
      <input type="text" name="title_field" id="title_field" />
      <span class="textfieldRequiredMsg">A value is required.</span></span></label></td>
    </tr>
  <tr>
    <td>Description:*</td>
    <td><span id="sprytextarea1">
    <label for="description_field"></label>
    <textarea name="description_field" id="description_field" cols="45" rows="3"></textarea>
    <span id="countsprytextarea1">&nbsp;</span><span class="textareaRequiredMsg">A value is required.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
    </tr>
  <tr>
    <td>Webmaster Name:*</td>
    <td><label for="textfield2"><span id="sprytextfield4">
      <input type="text" name="webmaster_nane_field" id="webmaster_nane_field" />
      <span class="textfieldRequiredMsg">A value is required.</span></span></label></td>
    </tr>
  <tr>
    <td>Webmaster E-mail:*</td>
    <td><label for="textfield3"><span id="sprytextfield5">
    <input name="webmaster_email_field" type="text" id="webmaster_email_field" size="40" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></label></td>
    </tr>
  <tr>
    <td>Category:*</td>
    <td><span id="spryselect1">
      <label for="category_selection"></label>
      <select name="category_selection" id="category_selection">
        <option>Select An Option</option>
        <option value="Web_Sites">Web Sites</option>
        <option value="Blogs">Blogs</option>
        <option value="Directories">Directories</option>
      </select>
<span class="selectRequiredMsg">Please select an item.</span></span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><label for="select"></label>
      <input type="submit" name="button" id="button" value="Url Submission" /></td>
    </tr>
</table>
<input type="hidden" name="MM_insert" value="link_submission" />
</form>

Can i have some help here please?\

Thanks in advance for any guidance.

In all three if statements you have the same error - on equal sign instead of two. EX: ...&& ($site_type [B]=[/B] "...") it should be: ...&& ($site_type [B]==[/B] "...")

In all three if statements you have the same error - on equal sign instead of two. EX: ...&& ($site_type [B]=[/B] "...") it should be: ...&& ($site_type [B]==[/B] "...")

No it didnt worked...
Maybe the best way is to do it with arrays, but i didnt made it.. never been too much in love with arrays anyway..
Does anyone knows how to do it pls? :(

is that ALL the code? I don't see you connecting to the DB nor defining the GetSQLValueString() function anywhere. I suspect you are doing this on a separate file, and if so you must include it as well.

is that ALL the code? I don't see you connecting to the DB nor defining the GetSQLValueString() function anywhere. I suspect you are doing this on a separate file, and if so you must include it as well.

To be exact this is the script

<?php require_once('Connections/content_conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$site_type = $_REQUEST['category_selection'];
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type == "Web_Sites")) {
  $insertSQL = sprintf("INSERT INTO partner_sites (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['url_field'], "text"),
                       GetSQLValueString($_POST['title_field'], "text"),
                       GetSQLValueString($_POST['anchor_field'], "text"),
                       GetSQLValueString($_POST['description_field'], "text"),
                       GetSQLValueString($_POST['webmaster_nane_field'], "text"),
                       GetSQLValueString($_POST['webmaster_email_field'], "text"),
                       GetSQLValueString($_POST['category_selection'], "text"));

  mysql_select_db($database_content_conn, $content_conn);
  $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); 

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type == "Blogs")) {
  $insertSQL = sprintf("INSERT INTO partner_blogs (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['url_field'], "text"),
                       GetSQLValueString($_POST['title_field'], "text"),
                       GetSQLValueString($_POST['anchor_field'], "text"),
                       GetSQLValueString($_POST['description_field'], "text"),
                       GetSQLValueString($_POST['webmaster_nane_field'], "text"),
                       GetSQLValueString($_POST['webmaster_email_field'], "text"),
                       GetSQLValueString($_POST['category_selection'], "text"));

  mysql_select_db($database_content_conn, $content_conn);
  $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error());

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type == "Directories")) {
  $insertSQL = sprintf("INSERT INTO partner_directories (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['url_field'], "text"),
                       GetSQLValueString($_POST['title_field'], "text"),
                       GetSQLValueString($_POST['anchor_field'], "text"),
                       GetSQLValueString($_POST['description_field'], "text"),
                       GetSQLValueString($_POST['webmaster_nane_field'], "text"),
                       GetSQLValueString($_POST['webmaster_email_field'], "text"),
                       GetSQLValueString($_POST['category_selection'], "text"));

  mysql_select_db($database_content_conn, $content_conn);
  $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error());
}
?>

But.. is not working...
The html is the same as in original post in the begining of the thread.

Do you get any errors? Have you tried putting echo statements WITHIN the if clauses to see if any of the if clauses are getting executed or not?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.