The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

3 Pages V  1 2 3 >  
Reply to this topicStart new topic
> Prepared statements
MindyT
post Nov 18 2015, 03:57 PM
Post #1


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



iH, i'm I work with prepared statements and I'm having trouble understanding what go s in this part.
CODE
VALUES (?,?,NOW(),?,?)');
$stmt -> bind_param('ssi',     



from this block of code
CODE

$stmt = $mysqli -> prepare('INSERT INTO clients fname,lname,orgName,address,city,state,zipcode,phone,fax,email,confirmEmail,proj
ectOptions,projectOverview,year);
                            VALUES (?,?,NOW(),?,?)');
$stmt -> bind_param('ssi',         VALUES  ('$_POST[fname]','$_POST[lname]','$_POST[orgName]','$_POST[address]','$_POST[city]','$_POST[state]','$_POST[zipcode]','$_POST[phone]','$_POST[fax]','$_POST[email]','$_POST[confirmEmail]','$_POST[projectOptions]','$_POST[projectOverview]','$_POST[year]' );
$stmt -> execute();
$stmt -> close();



Do you just put question marks for every field that's going in the table?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 18 2015, 04:34 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Based on your INSERT INTO statement you are inserting values into these columns:
'fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year'
So, you would use this in the order of the column names:
bind_param('sssssssssssssi', $_POST[fname], $_POST[lname], $_POST[orgName], etc, etc.....);

The 'sssssssssssssi' part specifies the data type for each column. You can choose from 4 types:
i corresponding variable has type integer
d corresponding variable has type double
s corresponding variable has type string
b corresponding variable is a blob and will be sent in packets

Also, you might have to use double quotes instead of single quotes around the SQL statement.

Edit: After I posted I noticed that the forum software had converted a single quote into '& #39;', I had to add a space after each comma, in the column names, in order to get it to post correctly.

This post has been edited by CharlesEF: Nov 18 2015, 04:40 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 18 2015, 04:48 PM
Post #3


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



I forgot to mention that you really should use php's filter_var commands to sanitize your user input before you insert it into the database. See here.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 18 2015, 05:06 PM
Post #4


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



Thanks so much for explaining it. That really helps!

QUOTE(CharlesEF @ Nov 18 2015, 04:34 PM) *

Based on your INSERT INTO statement you are inserting values into these columns:
'fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year'
So, you would use this in the order of the column names:
bind_param('sssssssssssssi', $_POST[fname], $_POST[lname], $_POST[orgName], etc, etc.....);

The 'sssssssssssssi' part specifies the data type for each column. You can choose from 4 types:
i corresponding variable has type integer
d corresponding variable has type double
s corresponding variable has type string
b corresponding variable is a blob and will be sent in packets

Also, you might have to use double quotes instead of single quotes around the SQL statement.

Edit: After I posted I noticed that the forum software had converted a single quote into '& #39;', I had to add a space after each comma, in the column names, in order to get it to post correctly.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 19 2015, 12:21 PM
Post #5


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



Do I still need this line of code?
VALUES (?,?,NOW(),?,?)');
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 19 2015, 12:39 PM
Post #6


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(MindyT @ Nov 19 2015, 11:21 AM) *

Do I still need this line of code?
VALUES (?,?,NOW(),?,?)');

Yes, that is part of the SQL query. You need as many ? as you have column names. So, you had 14 column names so you need 14 ? marks. Sorry, I should have put that in also.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 19 2015, 01:02 PM
Post #7


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



thanks for explaining that in more detail. It helps me understand it better.

I'm reading up on sanitizing data and I understand why you would want to do it for email addresses, but why would you want to do it for every field?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 19 2015, 01:23 PM
Post #8


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(MindyT @ Nov 19 2015, 12:02 PM) *

thanks for explaining that in more detail. It helps me understand it better.

I'm reading up on sanitizing data and I understand why you would want to do it for email addresses, but why would you want to do it for every field?

Because SQL injection attacks can happen on any field. You should use, at least, Sanitize filters and Validate filters. Validate filters are used to make sure the data is in a required format, such as an email address or string only or integers only. Sanitize filters are used to remove characters that might be used in SQL injection attacks.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 19 2015, 03:25 PM
Post #9


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



I'm sorry. Now it says there's an unexpected ; on line 9 but everything looks ok

CODE

require_once('functions.php');
databaseConnection();
$stmt = $mysqli -> prepare("INSERT INTO clients fname,lname,orgName,address,city,state,zipcode,phone,fax,email,confirmEmail,proj
ectOptions,projectOverview,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt -> bind_param('sssssssssssssi', $_POST[fname],$_POST[lname],$_POST[orgName],$_POST[address],$_POST[city],$_POST[state],$_POST[zipcode],$_POST[phone],$_POST[fax],$_POST[email],$_POST[confirmEmail], $_POST[projectOptions],$_POST[projectOverview],$_POST[year] );
$stmt -> execute();
$stmt -> close();
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
masonh928
post Nov 19 2015, 06:33 PM
Post #10


Serious Coder
*****

Group: Members
Posts: 253
Joined: 17-August 13
From: Indiana
Member No.: 19,570



an alternative option, besides Using PDO, as long as you're not using mysql_* functions I'm fine; anyways, I believe you may use syntax like this.

CODE

$Query = $mysqli->prepare("INSERT INTO Table (Column) VALUES(?) ");
$Query->execute(array($ValueToInsert));
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 19 2015, 08:03 PM
Post #11


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



would I replace the code I have with what you have?
QUOTE(masonh928 @ Nov 19 2015, 06:33 PM) *

an alternative option, besides Using PDO, as long as you're not using mysql_* functions I'm fine; anyways, I believe you may use syntax like this.

CODE

$Query = $mysqli->prepare("INSERT INTO Table (Column) VALUES(?) ");
$Query->execute(array($ValueToInsert));


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
masonh928
post Nov 19 2015, 09:46 PM
Post #12


Serious Coder
*****

Group: Members
Posts: 253
Joined: 17-August 13
From: Indiana
Member No.: 19,570



Like this:

CODE

require_once('functions.php');
databaseConnection();
$stmt = $mysqli -> prepare("INSERT INTO clients fname,lname,orgName,address,city,state,zipcode,phone,fax,email,confirmEmail,proj

ectOptions,projectOverview,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt -> execute(array($FName, $Lname, $orgName, etc));
$stmt -> close();
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 19 2015, 10:12 PM
Post #13


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



now i'm getting this error

Fatal error: Call to a member function prepare() on a non-object in /web/html/mediaservicesunlimited.com/contactTest.php on line 9
'
CODE

<!doctype html>
<html lang="en">  
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<?php
require_once('functions.php');
databaseConnection();
$query = $mysqli->prepare("INSERT INTO clients VALUES(?) ");
$query->execute(array($ValuesToInsert));
/ *fname,lname,orgName,address,city,state,zipcode,phone,fax,email,confirmEmail,pro
jectOptions,projectOverview,year)
    VALUES=($_POST[fname],$_POST[lname],$_POST[orgName],$_POST[address],$_POST[city],$_POST[state],$_POST[zipcode],$_POST[phone],$_POST[fax],$_POST[email],$_POST[confirmEmail], $_POST[projectOptions],$_POST[projectOverview],$_POST[year] )";
    /*if(isset($_POST['submit'])) {
        
    }
$stmt = $mysqli ->prepare("INSERT INTO clients fname,lname,orgName,address,city,state,zipcode,phone,fax,email,confirmEmail,proj
ectOptions,projectOverview,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt -> bind_param('sssssssssssssi', $_POST[fname],$_POST[lname],$_POST[orgName],$_POST[address],$_POST[city],$_POST[state],$_POST[zipcode],$_POST[phone],$_POST[fax],$_POST[email],$_POST[confirmEmail], $_POST[projectOptions],$_POST[projectOverview],$_POST[year] );
$stmt -> execute();
$stmt -> close(); */
?>
</head>

<body>
  <form action ="contactUs.php" method="post">
         <label>  
                  <input id = "fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" >    <?php echo !empty($error['fname']) ? $error['fname'] : '';?>
                   <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?>
            <input type="text" name="orgName"  placeholder="Organization's Name"maxlength="50">
                </label><br />
            <label> <!--new row -->  
                  <input id = "address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50">
                  <input id = "city" type="text" name="city" placeholder="City" size="10" maxlength="25">
                  <select id  = "state" name = "state" placeholder="State" value="">
                     <option value ="Please choose a state">
                        Please choose a state
                     </option>
                     <?php states($state); ?>
                          </select>
                <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5">
             </label><br />
             <label> <!--new row -->
                  <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10">  
</label>        
                  <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10">
            </label><br />
            <label> <!--new row-->
                  <input type="text" id = "email" name="email" placeholder="Email Address" />
                  <input type="text" id = "confirmEmail" name="ConfirmEmail" placeholder="Confirm Email Address" />
</label><br />
            <label> <!--new row -->
            What would you like help with?
             <table id="projectOptions">
                     <tr span=2>
                        <td><input type="checkbox" name="SocialMedia">Social Media </td>
                        <td><input type="checkbox" name="WebContentManagement">Web Content Management     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation  </td>
                        <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="VideoEditing"> Video Editing  </td>
                        <td><input type="checkbox" name="WebDesign">Web Design      </td>
                     </tr>
                  </table>
</label>                
Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea>  <br />
If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br />
<input type="submit" name="submit" value="Contact Me!">
<input type="reset" name="reset" value="Cancel">
         </form>
</body>
</html>


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 20 2015, 03:34 AM
Post #14


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Why is this code here anyway:
CODE
$query = $mysqli->prepare("INSERT INTO clients VALUES(?) ");
$query->execute(array($ValuesToInsert));
It doesn't look like valid SQL to me.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 20 2015, 09:26 AM
Post #15


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



I took those lines out and still getting this error message.


Parse error: syntax error, unexpected T_VARIABLE in /web/html/mediaservicesunlimited.com/contactTest.php on line 13

CODE
'<!doctype html>
<html lang="en">  
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<?php
require_once('functions.php');
databaseConnection();
    /*if(isset($_POST['submit'])) {
        
    } */
$stmt = $mysqli ->prepare("INSERT INTO clients fname,lname,orgName,address,city,state,zipcode,phone,fax,email,confirmEmail,proj
ectOptions,projectOverview,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
$stmt -> bind_param('sssssssssssssi',
$_POST[fname],$_POST[lname],$_POST[orgName],$_POST[address],$_POST[city],$_POST[state],$_POST[zipcode],$_POST[phone],$_POST[fax],$_POST[email],$_POST[confirmEmail], $_POST[projectOptions],$_POST[projectOverview],$_POST[year] );
$stmt -> execute();
$stmt -> close();
?>
</head>

<body>
  <form action ="contactUs.php" method="post">
         <label>  
                  <input id = "fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" >    <?php echo !empty($error['fname']) ? $error['fname'] : '';?>
                   <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?>
            <input type="text" name="orgName"  placeholder="Organization's Name"maxlength="50">
                </label><br />
            <label> <!--new row -->  
                  <input id = "address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50">
                  <input id = "city" type="text" name="city" placeholder="City" size="10" maxlength="25">
                  <select id  = "state" name = "state" placeholder="State" value="">
                     <option value ="Please choose a state">
                        Please choose a state
                     </option>
                     <?php states($state); ?>
                          </select>
                <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5">
             </label><br />
             <label> <!--new row -->
                  <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10">  
</label>        
                  <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10">
            </label><br />
            <label> <!--new row-->
                  <input type="text" id = "email" name="email" placeholder="Email Address" />
                  <input type="text" id = "confirmEmail" name="ConfirmEmail" placeholder="Confirm Email Address" />
</label><br />
            <label> <!--new row -->
            What would you like help with?
             <table id="projectOptions">
                     <tr span=2>
                        <td><input type="checkbox" name="SocialMedia">Social Media </td>
                        <td><input type="checkbox" name="WebContentManagement">Web Content Management     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation  </td>
                        <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="VideoEditing"> Video Editing  </td>
                        <td><input type="checkbox" name="WebDesign">Web Design      </td>
                     </tr>
                  </table>
</label>                
Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea>  <br />
If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br />
<input type="submit" name="submit" value="Contact Me!">
<input type="reset" name="reset" value="Cancel">
         </form>
</body>
</html>

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 20 2015, 11:52 AM
Post #16


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



It appears the code is running when you load the page and you were missing a ; at the end of a line 13. Try this:

CODE
<!doctype html>
<html lang="en">  
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<?php
require_once('functions.php');
if(isset($_POST['submit'])) {
  databaseConnection();
  $stmt = $mysqli ->prepare("INSERT INTO clients (fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  $stmt -> bind_param('sssssssssssssi', $_POST[fname], $_POST[lname], $_POST[orgName], $_POST[address], $_POST[city], $_POST[state], $_POST[zipcode], $_POST[phone], $_POST[fax], $_POST[email], $_POST[confirmEmail], $_POST[projectOptions], $_POST[projectOverview], $_POST[year]);
  $stmt -> execute();
  $stmt -> close();
}
?>
</head>

<body>
  <form action ="contactUs.php" method="post">
         <label>  
                  <input id = "fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" >    <?php echo !empty($error['fname']) ? $error['fname'] : '';?>
                   <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?>
            <input type="text" name="orgName"  placeholder="Organization's Name"maxlength="50">
                </label><br />
            <label> <!--new row -->  
                  <input id = "address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50">
                  <input id = "city" type="text" name="city" placeholder="City" size="10" maxlength="25">
                  <select id  = "state" name = "state" placeholder="State" value="">
                     <option value ="Please choose a state">
                        Please choose a state
                     </option>
                     <?php states($state); ?>
                          </select>
                <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5">
             </label><br />
             <label> <!--new row -->
                  <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10">  
</label>        
                  <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10">
            </label><br />
            <label> <!--new row-->
                  <input type="text" id = "email" name="email" placeholder="Email Address" />
                  <input type="text" id = "confirmEmail" name="ConfirmEmail" placeholder="Confirm Email Address" />
</label><br />
            <label> <!--new row -->
            What would you like help with?
             <table id="projectOptions">
                     <tr span=2>
                        <td><input type="checkbox" name="SocialMedia">Social Media </td>
                        <td><input type="checkbox" name="WebContentManagement">Web Content Management     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation  </td>
                        <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="VideoEditing"> Video Editing  </td>
                        <td><input type="checkbox" name="WebDesign">Web Design      </td>
                     </tr>
                  </table>
</label>                
Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br />
If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br />
<input type="submit" name="submit" value="Contact Me!">
<input type="reset" name="reset" value="Cancel">
         </form>
</body>
</html>


This post has been edited by CharlesEF: Nov 20 2015, 12:04 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 20 2015, 01:44 PM
Post #17


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



It 's getting closer. When the form is displayed and I fill the form out and click contact me, I get

Fatal error: Call to a member function prepare() on a non-object in /web/html/mediaservicesunlimited.com/contactTest.php on line 10


CODE

<!doctype html>
<html lang="en">  
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<?php
require_once('functions.php');
if(isset($_POST['submit'])) {
  databaseConnection();
  $stmt = $mysqli ->prepare("INSERT INTO clients (fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  $stmt -> bind_param('sssssssssssssi', $_POST[fname], $_POST[lname], $_POST[orgName], $_POST[address], $_POST[city], $_POST[state], $_POST[zipcode], $_POST[phone], $_POST[fax], $_POST[email], $_POST[confirmEmail], $_POST[projectOptions], $_POST[projectOverview], $_POST[year]);
  $stmt -> execute();
  $stmt -> close();
}
?>
</head>

<body>
  <form action ="contactTest.php" method="post">
         <label>  
                  <input id = "fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" >    <?php echo !empty($error['fname']) ? $error['fname'] : '';?>
                   <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?>
            <input type="text" name="orgName"  placeholder="Organization's Name"maxlength="50">
                </label><br />
            <label> <!--new row -->  
                  <input id = "address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50">
                  <input id = "city" type="text" name="city" placeholder="City" size="10" maxlength="25">
                  <select id  = "state" name = "state" placeholder="State" value="">
                     <option value ="Please choose a state">
                        Please choose a state
                     </option>
                     <?php states($state); ?>
                          </select>
                <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5">
             </label><br />
             <label> <!--new row -->
                  <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10">  
</label>        
                  <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10">
            </label><br />
            <label> <!--new row-->
                  <input type="text" id = "email" name="email" placeholder="Email Address" />
                  <input type="text" id = "confirmEmail" name="ConfirmEmail" placeholder="Confirm Email Address" />
</label><br />
            <label> <!--new row -->
            What would you like help with?
             <table id="projectOptions">
                     <tr span=2>
                        <td><input type="checkbox" name="SocialMedia">Social Media </td>
                        <td><input type="checkbox" name="WebContentManagement">Web Content Management     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation  </td>
                        <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)     </td>
                     </tr>
                     <tr>
                        <td><input type="checkbox" name="VideoEditing"> Video Editing  </td>
                        <td><input type="checkbox" name="WebDesign">Web Design      </td>
                     </tr>
                  </table>
</label>                
Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br />
If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br />
<input type="submit" name="submit" value="Contact Me!">
<input type="reset" name="reset" value="Cancel">
         </form>
</body>
</html>


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 20 2015, 01:51 PM
Post #18


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



I am so sorry for all the questions. Once I understand how to get the form data into the database I should not have as many questions.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Nov 20 2015, 02:18 PM
Post #19


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(MindyT @ Nov 20 2015, 12:51 PM) *

I am so sorry for all the questions. Once I understand how to get the form data into the database I should not have as many questions.
Not a problem, everyone has to learn.

I need to see your code for 'functions.php'. The error you are getting now tells me that $mysqli is not an object. Which is why I need to see the other code also. At least post the code for the databaseConnection() function.

This post has been edited by CharlesEF: Nov 20 2015, 02:19 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
MindyT
post Nov 20 2015, 02:48 PM
Post #20


Advanced Member
****

Group: Members
Posts: 165
Joined: 12-November 13
Member No.: 19,963



Thank you so much for being so nice!

CODE

<?PHP
function states($states)
    {

        echo "<option value = \"AL\"";if($states == "AL"){ echo ' SELECTED';  }echo">AL</option>";
        echo "<option value = \"AK\"";if($states == "AK"){ echo ' SELECTED';  }echo">AK</option>";
        echo "<option value = \"AR\"";if($states == "AR"){ echo ' SELECTED';  }echo">AR</option>";
        echo "<option value = \"AZ\"";if($states == "AZ"){ echo ' SELECTED';  }echo">AZ</option>";
        echo "<option value = \"CA\"";if($states == "CA"){ echo ' SELECTED';  }echo">CA</option>";
        echo "<option value = \"CO\"";if($states == "CO"){ echo ' SELECTED';  }echo">CO</option>";
        echo "<option value = \"CT\"";if($states == "CT"){ echo ' SELECTED';  }echo">CT</option>";
        echo "<option value = \"DE\"";if($states == "DE"){ echo ' SELECTED';  }echo">DE</option>";
        echo "<option value = \"DC\"";if($states == "DC"){ echo ' SELECTED';  }echo">DC</option>";
        echo "<option value = \"FL\"";if($states == "FL"){ echo ' SELECTED';  }echo">FL</option>";
        echo "<option value = \"GA\"";if($states == "GA"){ echo ' SELECTED';  }echo">GA</option>";
        echo "<option value = \"HI\"";if($states == "HI"){ echo ' SELECTED';  }echo">HI</option>";
        echo "<option value = \"IA\"";if($states == "IA"){ echo ' SELECTED';  }echo">IA</option>";
        echo "<option value = \"ID\"";if($states == "ID"){ echo ' SELECTED';  }echo">ID</option>";
        echo "<option value = \"IL\"";if($states == "IL"){ echo ' SELECTED';  }echo">IL</option>";
        echo "<option value = \"IN\"";if($states == "IN"){ echo ' SELECTED';  }echo">IN</option>";
        echo "<option value = \"KS\"";if($states == "KS"){ echo ' SELECTED';  }echo">KS</option>";
        echo "<option value = \"KY\"";if($states == "KY"){ echo ' SELECTED';  }echo">KY</option>";
        echo "<option value = \"LA\"";if($states == "LA"){ echo ' SELECTED';  }echo">LA</option>";
        echo "<option value = \"MA\"";if($states == "MA"){ echo ' SELECTED';  }echo">MA</option>";
        echo "<option value = \"ME\"";if($states == "ME"){ echo ' SELECTED';  }echo">ME</option>";
        echo "<option value = \"MD\"";if($states == "MD"){ echo ' SELECTED';  }echo">MD</option>";
        echo "<option value = \"MI\"";if($states == "MI"){ echo ' SELECTED';  }echo">MI</option>";
        echo "<option value = \"MN\"";if($states == "MN"){ echo ' SELECTED';  }echo">MN</option>";
        echo "<option value = \"MO\"";if($states == "MO"){ echo ' SELECTED';  }echo">MO</option>";
        echo "<option value = \"MS\"";if($states == "MS"){ echo ' SELECTED';  }echo">MS</option>";
        echo "<option value = \"MT\"";if($states == "MT"){ echo ' SELECTED';  }echo">MT</option>";
        echo "<option value = \"NC\"";if($states == "NC"){ echo ' SELECTED';  }echo">NC</option>";    
        echo "<option value = \"ND\"";if($states == "ND"){ echo ' SELECTED';  }echo">ND</option>";
        echo "<option value = \"NE\"";if($states == "NE"){ echo ' SELECTED';  }echo">NE</option>";
        echo "<option value = \"NH\"";if($states == "NH"){ echo ' SELECTED';  }echo">NH</option>";
        echo "<option value = \"NJ\"";if($states == "NJ"){ echo ' SELECTED';  }echo">NJ</option>";
        echo "<option value = \"NM\"";if($states == "NM"){ echo ' SELECTED';  }echo">NM</option>";
        echo "<option value = \"OH\"";if($states == "OH"){ echo ' SELECTED';  }echo">OH</option>";
        echo "<option value = \"OK\"";if($states == "OK"){ echo ' SELECTED';  }echo">OK</option>";
        echo "<option value = \"OR\"";if($states == "OR"){ echo ' SELECTED';  }echo">OR</option>";
        echo "<option value = \"PA\"";if($states == "PA"){ echo ' SELECTED';  }echo">PA</option>";
        echo "<option value = \"RI\"";if($states == "RI"){ echo ' SELECTED';  }echo">RI</option>";
        echo "<option value = \"SC\"";if($states == "SC"){ echo ' SELECTED';  }echo">SC</option>";
        echo "<option value = \"SD\"";if($states == "SD"){ echo ' SELECTED';  }echo">SD</option>";
        echo "<option value = \"TN\"";if($states == "TN"){ echo ' SELECTED';  }echo">TN</option>";
        echo "<option value = \"TX\"";if($states == "TX"){ echo ' SELECTED';  }echo">TX</option>";
        echo "<option value = \"UT\"";if($states == "UT"){ echo ' SELECTED';  }echo">UT</option>";
        echo "<option value = \"VA\"";if($states == "VA"){ echo ' SELECTED';  }echo">VA</option>";
        echo "<option value = \"VT\"";if($states == "VT"){ echo ' SELECTED';  }echo">VT</option>";
        echo "<option value = \"WA\"";if($states == "WA"){ echo ' SELECTED';  }echo">WA</option>";
        echo "<option value = \"WI\"";if($states == "WI"){ echo ' SELECTED';  }echo">WI</option>";
         echo "<option value = \"WV\"";if($states == "WV"){ echo ' SELECTED';  }echo">WV</option>";
         echo "<option value = \"WY\"";if($states == "WY"){ echo ' SELECTED';  }echo">WY</option>";
    }
//database connection
function databaseConnection() {
$hostname = "hercules.xymmetrix.net";
$username = "";
$password = "";
try {
    
    $db = new PDO("mysql:host=$hostname;dbname=www_mediaservicesunlimited_com", $username, $password);
    }
catch(PDOException $e)
        {
    echo $e->getMessage();
    }
}
?>



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

3 Pages V  1 2 3 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 02:39 AM