form data is not saving in to database after submit, if i use fancybox in php

[php]<?php
var_dump($_GET[‘u’]);
include(“connection.php”);
include(“uploadimage.php”);

if(isset($_POST['txtStartup']))
{
    $sName = $_POST["txtStartup"];
    $sUserName = '';
    if(isset($_GET['u']))
    {
        $sUserName = $_GET['u'];
    }
    else
    {
        header("location:index.php");
    }
    uploadimage();
    $sDescription = $_POST["txtDescription"];
    $sSql = "INSERT INTO communities(name, description, ownerid, image)VALUES('$sName', '$sDescription', '$sUserName', '$newfilename')";
    $result = mysql_query($sSql);
    if($result > 0)
    {
        echo "go";
        echo "";
}
else
{
    echo "no";
    echo "<script>alert('Startup already exists..!!')</script>";
}

}
else
{
echo “”;
}

?>

body{margin: 2px 2px 0px 2px; font-family: Courier New;} input[type=text], textarea { -webkit-transition: all 0.30s ease-in-out; -moz-transition: all 0.30s ease-in-out; -ms-transition: all 0.30s ease-in-out; -o-transition: all 0.30s ease-in-out; outline: none; padding: 3px 0px 3px 3px; margin: 5px 1px 3px 0px; border: 2px solid #DDDDDD; -webkit-border-radius: 11px 10px 12px 10px;-moz-border-radius: 11px 10px 12px 10px;border-radius: 11px 10px 12px 10px; width:236px; } input[type=text]:hover, textarea:hover { box-shadow: 0 0 5px rgba(81, 203, 238, 1); padding: 3px 0px 3px 3px; margin: 5px 1px 3px 0px; border: 2px solid rgba(81, 203, 238, 1); -webkit-border-radius: 11px 10px 12px 10px;-moz-border-radius: 11px 10px 12px 10px;border-radius: 11px 10px 12px 10px; } #dvMain{border-radius: 1px;} /* input[type=button]{width: 77px; background-color:#003366;border-radius: 5px; color: white ;border: 1px solid #000066;} input[type=button]:hover{background-color:#9dbcda;} */ table{background-color: #ffffff;} .p{color: #ff6347;font-family: Comic Sans MS;font-size: 11px;font-style: normal;} .btn, .btn input[type=image]{float: left; width: 76px;height: 26px;background-color:#003366;border-radius: 5px; color: white ;border: 0px solid #000066;} td{border: 0px solid #ffffff;} tr:hover{background-color:#FAFAFA;} Add Startup

CREATE STARTUP

Name:
Description:
Upload image:
   


What is startup ? Brief startup here for user information ...!!

[/php] --------------------------------------- I am using fancybox to open this page and submit data in db. this works in normal popup like in window.open. But it does not save form data in db if i use fancybox.

Here are code which i use to open this page in fancybox
Add Startups

Few things i noticed.

  1. What is
     for?
  2. That should echoed, otherwise it’ll produce an error message
  3. Change $result = mysql_query($sSql); to $result = mysql_query($sSql) or die(mysql_error()); That’ll at least tell you if you any query errors.
  4. [php]$sSql = “INSERT INTO communities(name, description, ownerid, image)VALUES(’$sName’, ‘$sDescription’, ‘$sUserName’, ‘$newfilename’)”;
    $result = mysql_query($sSql);
    if($result > 0)
    {
    echo “go”;
    echo “”;
    }
    else
    {
    echo “no”;
    echo “”;
    }
    }
    else
    {
    echo “”;
    }[/php] May be giving you false messages, depending on how you have your keys set up. I would do a separate query first to check to see if the person or community exists already. Then if not, do the insert, else return an error message.
  5. I don’t see where you’re using the validation function.
  6. you have 2 open div tags and no termination for either one, that’ll likely give you some weird layout issues.

But more than likely, you either have something wrong with the query or the information isn’t getting there. Since this is going in a popup, change the form action to the name of the page.

Sponsor our Newsletter | Privacy Policy | Terms of Service