I am getting message while trying to access my page. $config['DB_HOST'] = 'localhost'; $config['DB_USER'] = '****'; $config['DB_PASS'] = ''; $config['DB_NAME'] ='**********' ;
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /home/***/public_html/init.php on line 4
Connect failed: Access denied for user 'root'@'localhost' (using password: NO)
config2.php
$config['DB_HOST'] = 'localhost';
$config['DB_USER'] = '*******';
$config['DB_PASS'] = '********';
$config['DB_NAME'] ='************** ;
init.php
<?php
include_once('config2.php');
$conn=mysqli_connect($config['DB_HOST'], $config['DB_USER'], $config['DB_PASS'],$config['DB_NAME']);
?>
my form information:
<?php
include_once('init.php');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
};
if(isset($_POST['submit'])) {
if (!$_POST['fname'] ) {
$mes1='Please enter your First Name';}
elseif (!$_POST['lname'] ) {
$mes2='Please enter your Last Name';}
elseif (!$_POST['street_address'] ) {
$mes3='Please enter your Street Address';}
elseif (!$_POST['city'] ) {
$mes4='Please enter your City';}
elseif (!$_POST['state'] ) {
$mes5='Please enter your State';}
elseif (!$_POST['zip_code'] ) {
$mes6='Please enter your Zip Code';}
elseif (!$_POST['phone'] ) {
$mes7='Please enter your Phone Number';}
elseif (!$_POST['department'] ) {
$mes9='Please enter your Department';}
elseif (!$_POST['email'] ) {
$mes10='Please enter your Email Address';}
elseif (!$_POST['level']) {
$mes12='Please select a Level Of Training';}
elseif (!$_POST['pay']) {
$mes13='Please select a payment type';}
else {
echo "<p style=\"font-color=red;\"> Thank you $_POST[fname] !! Your registration has been submitted!! </p>".$sendEmail;
} }
if(isset($_POST['submit'])) {
// validate a phone number
if(!preg_match("/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/", $_POST['phone']));
// $phone is valid
echo $mes8;
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
// The email address is not valid
$meg11;
}}
$sendEmail=
$to = "********@hotmail.com,******@yahoo.com,*******@hotmail.com,********@ottawa-glandorfems.org";
$subject= 'Registration Information';
$fname= $_POST['fname'];
$lname= $_POST['lname'];
$email= $_POST['email'];
$street_address= $_POST['street_address'];
$city= $_POST['city'];
$state= $_POST['state'];
$zip_code= $_POST['zip_code'];
$phone= $_POST['phone'];
$department= $_POST['department'];
$level= $_POST['level'];
$pay= $_POST['pay'];
$header="From:$email";
$message=<<<EMAIL
My name is $fname $lname my email is $email. My address is $street_address $city , $state $zip_code. My phone number is $phone. I work for $department and my level of training is $level. My payment method is $pay.
EMAIL;
mail ($to, $subject , $message, $header);
if (isset($_POST['fname'], $_POST['lname'], $_POST['phone'], $_POST['street_address'], $_POST['city'], $_POST['state'], $_POST['zip_code'], $_POST['department'], $_POST['email'], $_POST['level'], $_POST['pay'])) {
$fname = mysqli_real_escape_string ($conn, trim($_POST['fname']));
$lname = mysqli_real_escape_string ($conn, trim($_POST['lname']));
$phone = mysqli_real_escape_string ($conn, trim($_POST['phone']));
$street_address = mysqli_real_escape_string ($conn, trim($_POST['street_address']));
$city = mysqli_real_escape_string ($conn, trim($_POST['city']));
$state = mysqli_real_escape_string ($conn, trim($_POST['state']));
$zip_code = mysqli_real_escape_string ($conn, trim($_POST['zip_code']));
$department = mysqli_real_escape_string ($conn, trim($_POST['department']));
$email = mysqli_real_escape_string ($conn, trim($_POST['email']));
$level = mysqli_real_escape_string ($conn, trim($_POST['level']));
$pay = mysqli_real_escape_string ($conn, trim($_POST['pay']));
$query ="INSERT INTO oktoberfest2014 SET
First_Name='{$fname}',
Last_Name='{$lname}',
Phone='{$phone}',
Address='{$street_address}',
City='{$city}',
State='{$state}',
Zip_Code='{$zip_code}',
Department='{$department}',
Email_Address='{$email}',
Level_of_Training='{$level}',
Pay='{$pay}'";
mysqli_query($conn, $query);
if (!mysqli_query($conn, $query)) {
printf("Errormessage: %s\n", mysqli_error($conn));
};
}
?>
<?php
?>
<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Dynalight' rel='stylesheet' type='text/css'>
<b> <title>Registration form for Octoberfest With O-G EMS 2014</title></b>
<style> .error {color: red;} </style>
<link rel="stylesheet" type="text/css" href="form.css">
</head><div class="header">
<body bgcolor=" burt orange"> <br><div align="center"><!--<img id="Oktoberfest Logo" src="/pics/oktoberfestweb.jpg" border="5" height="200" width="250"></div>--><br><br>
<div class="content">
<table style="background-color: gray; border: 1px dashed #999"><tr><td>
<center><form action="" method="post">
<b> <p><center><h1>Oktoberfest with O-G EMS</h1><br><h2>Registration form</h2></center></p></b>
<fieldset><legend><b><h2>General Information</h2></b></legend><b><label>First Name:</label><input type="text" name="fname" placeholder="First name" size="25" id="fname" value="<?php echo "$fname"?>"/>
<span class="error"> <b><?php echo "$mes1"; ?></b></span>
<p><label>Last Name:</label><input type="text" name="lname" size="25" placeholder="Last Name" id="lname" value="<?php echo "$lname"?>"/> </p><span class="error"><b><?php echo "$mes2";?></b> </span>
<p><label>Phone Number:</label><input type="text" name="phone" placeholder="Phone Number (xxx-xxx-xxxx)" size="30" id="phone" value="<?php echo "$phone"?>"/></p><span class="error"><b><?php echo "$mes7";?><?php echo "$mes8";?></b> </span>
<p><label>Address:</label><input type="text" name="street_address" size="30" placeholder="Street Address (P.O. Box)" id="street_address" value="<?php echo "$street_address"?>"/><span class="error"><b><?php echo "$mes3";?></b> </span><input type="text" name="city" size="10" placeholder="City" id="city" value="<?php echo "$city"?>"/><span class="error"><b><?php echo "$mes4";?><b> </span><input type="text" placeholder="State" name="state" size="5" id="state" value="<?php echo "$state"?>"/><span class="error"><b><?php echo "$mes5";?></b> </span><input type="text" name="zip_code" size="10" placeholder="Zip Code" id="zip_code" value="<?php echo "$zip_code"?>"/><span class="error"><b><?php echo "$mes6";?></b> </span>
<p><label>Department:</label><input type="text" name="department"size="25" placeholder="Department/Agency" id="department" value="<?php echo "$department"?>"/></p><span class="error"><b><?php echo "$mes9";?></b> </span>
<p><label>Email Address:</label><input type="text" name="email" size="40" placeholder="Email Address" id="email" value="<?php echo "$email"?>"/></p></center><span class="error"><b><?php echo "$mes10"; ?><?php echo "$mes11";?></b> </span>
</b></fieldset>
<fieldset><legend><b><h2><label>LEVEL OF TRAINING</label></h2></b></legend>
<p><b>(PLEASE NOTE IF YOU HAVE MULTIPLE LEVELS...<br>PLEASE CHOOSE THE ONE YOUR WILL BE ATTENDING FOR)</b></br><span class="error"><b><?php echo "$mes12";?></b> </span>
<input type="radio" name="level" value="EMR">EMR</br>
<input type="radio" name="level" value="EMT-B">EMT-B</br>
<input type="radio" name="level" value="EMT-I">EMT-I</br>
<input type="radio" name="level" value="EMT-P">EMT-P</br>
<input type="radio" name="level" value="Nurse">Nurse</br>
<input type="radio" name="level" value="Nurse-EMTB">Nurse/EMT-B</br>
<input type="radio" name="level" value="Nurse-EMTI">Nurse/EMT-I</br>
<input type="radio" name="level" value="Nurse-EMTP">Nurse/EMT-P</br></p></fieldset>
<fieldset><legend><b><h2><label>PAYMENT METHOD</label></h2></b></legend>
<p><b>(PLEASE NOTE IF YOU ARE NOT A PUTNAM COUNTY EMT OR FIREFIGHTER YOU NEED TO SELECT ONE OF THE BOTTOM 3 CHOICES)</b></br><br>
If you wish to mail your payment in please send payment to Ottawa-Glandorf EMS 305 N Taft Ave Ottawa, Oh 45875 and put "Oktoberfest" MEMO line please.<span class="error"><b><?php echo "$mes13";?></b> </span><br>
<input type="radio" name="pay" value="I do not need to pay.">I am a Putnam County EMT or a Putnam County Firefighter. </br>
<input type="radio" name="pay" value="I paid with Paypal.">I am not a Putnam County EMT or Firefighter and will pay by Paypal.</br>
<input type="radio" name="pay" value="I will send you my payment.">I am not a Putnam County EMT or Firefighter and will send my money in.</br>
<input type="radio" name="pay" value="I will pay the day of CE.">I am not a Putnam County EMT or Firefighter and will pay day of CE.</br></p></fieldset>
<input type="submit" name="submit" value="Register"><td align="left" valign="bottom"></form><table><tr>
<fieldset>
<legend><b><h2>If you are not a Putnam County Employee please pay HERE!</h2></b></legend>
<form action="https://www.paypal.com/cgi-bin/webscr" target ="_blank" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="V9XZ2NSAT5BWA">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form></tr> </table>
</fieldset>
</td>
</form></td></tr></table> </div>
</body>
</html>