What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    having trouble with MySQL

    Asked by The_Mighty_Optiq on October 03, 2012 at 12:20 AM

    I've been stuck for about a week trying to figure out how to get my login page to work and have been back and forth from forum to forum and the supposed tech support with the host JUST TO GET NOWHERE!!!!.... I'm hoping you guys can help me out.  The problem is.... I don't know enough about PHP to be able to identify it to tell you.... all I know is IT WON'T WORK!!!!... it involves 3 pages and so far I'm guessing it's rooting to my connection page... the coding for that is

     

    <?php

    /*  

    1: "die()" will exit the script and show an error statement if something goes wrong with the "connect" or "select" functions. 

    2: A "mysql_connect()" error usually means your username/password are wrong  

    3: A "mysql_select_db()" error usually means the database does not exist. 

    */ 

    // Place db host name. Sometimes "localhost" but  

    // sometimes looks like this: >>      ???mysql??.someserver.net 

    $db_host = "localhost"; 

    // Place the username for the MySQL database here 

    $db_username = "#";  

    // Place the password for the MySQL database here 

    $db_pass = "#";  

    // Place the name for the MySQL database here 

    $db_name = "#"; 

     

    // Run the actual connection here  

    mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");

    mysql_select_db("$db_name") or die ("no database");              

    ?>

     

    I hve a # in place of my username, password and database in here but I do have the right passwords in the file I have on my computer.

     

    The code for my login page is

     

    <?php

    session_start();

    if(!isset($_SESSION["manager"])){

    header("location:'http://www.optiq-customtees.zxq.net/storeadmin/admin_index.php'");

    exit();

    }

    ?>

    <?php

    //Parse the log in form if the user has filled it out and pressed "Log In"

    if(isset($_POST["username"])&&isset($POST["password"])){

    $manager=preg_replace('#[^A-Za-z0-9_]#i','',$_POST["username"]);//filter everything but numbers and letters

    $password=preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]);//filter everything but numbers and letters

    //Connect to the MySQL database

    include"http://www.optiq-customtees.zxq.net/storeadmin/connect_to_mysql.php";

    $sql=mysql_query("SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1");//query the person

    //---- MAKE SURE PERSON EXISTS IN DATABASEE ----

    $existCount=mysql_num_rows($sql);//count rows nums

    if($existCount==1){//evaluate the count

    while($row=mysql_fetch_array($sql)){

    $id=$row["id"];

    }

    $_SESSION["id"]=$id;

    $_SESSION["manager"]=$manager;

    $_SESSION["password"]=$password;

    header("location:http://www.optiq-customtees.zxq.net/storeadmin/admin_index.php");

    exit();

    }else{

    echo'That information is incorrect, try again <a target="_blank" href="http://www.optiq-customtees.zxq.net/storeadmin/admin_index.php" rel="nofollow">Click Here</a>';

    exit();}}?>

     

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Store Admin</title>

    <link rel="http://www.optiq-customtees.zxq.net/style/style.css" type="text/css" />

    </head>

     

    <body>

    <div align="center" id="mainWrapper">

    <?php include_once("http://www.optiq-customtees.zxq.net/template_header.php");?>

    <div id="pageContent"><br />

    <div align="left" style="margin-left:24px;">

            <h2>Please Log In To Manage Store</h2>

                <form id="form1" method="post" action="admin_login.php">

                User Name:<br />

                    <input name="username" type="text" id="username" size="40" />

                    <br /><br />

                    Password:<br />

                    <input name="password" type="password" id="password" size="40" />

                    <br />

                    <br />

                    <br />

                    <input type="submit" name="button" id="button" value="Log In" />

                </form>

                <p>&nbsp;</p>

            </div>

    </div>

        <br />

        <br />

    <?php include_once("http://www.optiq-customtees.zxq.net/template_footer.php");?>

     

    </div>

    </body>

    </html>

     

     

    my index page is

     

    <?php

    session_start();

    if(!isset($_SESSION["manager"])){

    header("location:http://www.optiq-customtees.zxq.net/storeadmin/admin_login.php");

    exit();

    ini_set('display_errors',1); 

     error_reporting(E_ALL);

    }

    //Be sure to check that this manager SESSION value is in fact in the database

    $managerID=preg_replace('#[^0-9]#i','',$_SESSION["id"]);//filter everything but numbers and letters

    $manager=preg_replace('#[^A-Za-z0-9_]#i','',$SESSION["manager"]);//filter everything but numbers and letters

    $password=preg_replace('#[^A-Za-z0-9]#i','',$SESSION["password"]);//filter everything but numbers and letters

    //Run mySQL quesry to be sure that this person is an admin and that their password session var equals the database information

    //Connect to the MySQL database

    include"http://www.optiq-customtees.zxq.net/storeadmin/connect_to_mysql.php";

    $sql=mysql_query("SELECT*FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1");//query the person

    //----- MAKE SURE PERSON EXISTS IN DATABASE ------

    $existCount=mysql_num_rows($sql);//count the row nums

    if ($existCount==0){// evaluate the count

    header("location:http://www.optiq-customtees.zxq.net/storeadmin/index.php");

    exit();

    }

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Store Admin</title>

    <link rel="http://www.optiq-customtees.zxq.net/style/style.css" type="text/css" />

    </head>

     

    <body>

    <div align="center" id="mainWrapper">

    <?php include_once("http://www.optiq-customtees.zxq.net/template_header.php");?>

    <div id="pageContent">

    <div align="left" style="margin-left:24px;">

            <h2>Hello Store manager what would you like to do today?</h2>

                <a target="_blank" href="#">Manage Inventory</a><br />

                <a target="_blank" href="#">Manage blahblahblah</a>

            </div>

    </div>

        <br />

        <br />

    <?php include_once("http://www.optiq-customtees.zxq.net/template_footer.php");?>

     

    </div>

     

    </body>

    </html>

     

     

    I have absolutely NO CLUE as to what I have wrong and haven't been able to get an answer out of anybody else that has worked....  a couple people said I needed to download a MySQL client on my computer... but then a few other people said I didn't... because I have other php pages I coded for creating the tables and that all worked out fine....  COULD SOMEONE PLEEEEEEEEASE HELP WITH THIS???!!!!!!

    meta problem style size POST
  • Profile Image
    JotForm Support

    Answered by fxr on October 03, 2012 at 02:51 AM

    This isnt really related to a JotForm form in anyway, so we unfortunately we cant really spend time helping you.

    You should be able to quickly find tutorials in google. 

  • Profile Image

    Answered by The_Mighty_Optiq on October 04, 2012 at 03:15 PM

    urrrr..... I understand... just thought I'd ask because NOBODY else seems to be able to figure it out... thanks anyways..

  • Profile Image
    JotForm Support

    Answered by Rodjit on October 04, 2012 at 03:21 PM

    Hi The_Mighty_Optig,

    You may try to search for free mySql forums. There a lot of genius out there. :)

    We are really sorry.

    Thanks

  • Profile Image

    Answered by khrisell on July 04, 2013 at 11:30 PM
    Greetings!

    We are happy to announce that we have released Jotform Webhooks,  this feature would replace Send Post Data + Custom URL Thank You Page workaround in order to help you transfer forms data to your own database using your own script codes.

    To know more about Jotform Webhooks, please click here.

     

    Thank you for using JotForm. :)