/    Sign up×
Community /Pin to ProfileBookmark

Pls help to resolve php contact form

Hello friends,

I’m new to php programming. I know less than nothing. I designed html page in which i want contact form which will be used to send the information to the given email ID.

I done the php script part by the help of material and online tutorials. but when i upload the files to the server, I’m getting error like this,

Access denied for user ‘root’@’Localhost’ to database ‘form’

when i asked this to my hosting provider, they asked me to provide my database connecting settings in my mysql connection string that i’m using in my code. But quite frankly i don’t know what that does mean.

I’m really in a tight position to upload the file to the server.

Here are my codes. Can anyone really help me to how to fix this issue?

config.php

[code=php]<?php
$host = ‘Localhost’;
$user = ‘root’;
$pass = ”;
$dbname = ‘form’;

$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
$selectdb = mysql_select_db($dbname,$conn) or die(mysql_error());
?>[/code]

function1.php

[code=php]<?php
require_once ‘config.php’;
session_start();

if(isset($_REQUEST[‘process’]))

{

$name=$_REQUEST[‘name’];
$email=$_REQUEST[’email’];
$mobile=$_REQUEST[‘mobile’];
$mess=$_REQUEST[‘message’];

$to=”[email protected]”;
$to=”[email protected]”;
$subject = “Contact Us”;
$message=”<html><head><title></title></head><body><center></center><br /><table border=’0′ cellpadding=’5′ cellspacing=’5′ align=’center’><tr><td> Name: </td><td>”.$name.”</td></tr> <tr><td> Email: </td><td>”.$email.”</td></tr> <tr><td> Mobile : </td><td>”.$mobile.”</td></tr> <tr><td> Message : </td><td>”.$mess.”</td></tr></table></body></html>”;

$headers = “MIME-Version: 1.0” . “rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1” . “rn”;
$headers .= “From: “.’calltuktuk.com’.” <from_address@your_domain.com>rn”;
$headers .= “Reply-To: “.’calltuktuk.com’.” <to_address@your_domain.com>rn”;

@mail($to, $subject, $message, $headers);

header(‘Location: index.php?true’);exit;
}

/*Contact form*/
function myform($vars)
{
$name= $vars[‘name’];
$email=$vars[’email’];
$mobile = $vars[‘mobile’];
$message = $vars[‘message’];

$selqry = “SELECT * FROM contact_form”;
$rsqry = mysql_query($selqry)or die(mysql_error()) ;
$cnt = mysql_num_rows($rsqry);

$insert = “INSERT INTO contact_form(name,email,mobile,message) VALUES(‘$name’,’$email’,’$mobile’,’$message’)”;
$rscourse=mysql_query($insert) or die (mysql_error());
$lastid = mysql_insert_id();

header(‘Location:index.php?true’);exit;
}
?>
[/code]

Thanks in advance.

Regards,
Sam

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @design_student spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...