PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1847
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Pls help to resolve php contact form issue Posted by designstudent on 17 Oct 2011 at 4:02 AM
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

<?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());
    ?>



function1.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="sakmak1@gmail.com";
        $to="cappv2010@gmail.com";
         $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" . "\r\n";
         $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
         $headers .= "From: ".'calltuktuk.com'." <from_address@your_domain.com>\r\n";
       $headers .= "Reply-To: ".'calltuktuk.com'." <to_address@your_domain.com>\r\n";
         
       @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;
                }
             ?>


Thanks in advance.
Regards,
Sam
Report
Re: Pls help to resolve php contact form issue Posted by debtrelief on 6 Nov 2011 at 10:07 PM
YOU CAN INSERT THIS TO HTML PAGE AND YOU CAN SAVE AS .htm

<form id="form" name="form" method="post" action="form.php">
<table width="450" border="0" bordercolor="003366">
<tr>
<td width="100">Name</td>
<td width="10">:</td>
<td width="251"><label>
<input name="name" type="text" id="name" size="40" />
</label></td>
<td width="71">*</td>
</tr>
<tr>
<td>Email Address </td>
<td>:</td>
<td><input name="email" type="text" id="email" size="40" /></td>
<td>*</td>
</tr>
<tr>
<td align="left" valign="top">Message</td>
<td valign="top">:</td>
<td align="left" valign="top"><label>
<textarea name="message" cols="30" id="message"></textarea>
</label></td>
<td align="left" valign="top">*</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="submit" onclick="return validate_form()" value="Submit" />
<label>
<input type="reset" name="Reset" value="Reset" />
[*] Required fields </label></td>
<td>&nbsp;</td>
</tr>
</table>
</form>


BUT IN THIS AREA
YOU CAN INSERT THIS TO YOUR PHP PAGE AND YOU CAN SAVE AS form.php

<?PHP
$to = "YOUR EMAIL@yahoo.com";
$title .= "Inquiry from YOURSITE\n\n";

$msg .= "Name: $name\n";
$msg .= "Email: $email\n";

$msg .= "Message: $message\n";
mail($to, $title, $msg, "From:YOURSITE.net\nReply-To: $email\n");
?>


Debt Relief



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.