Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi sir or madam,
I am new to php coding.
I have php and html coding individually. Please combine the code to run my application.

Code:

HTML
<!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>Untitled Document</title>
<style type="text/css">
<!--
@import url("css/styles.css");
-->
</style>
</head>


<body>
<form>
          <div class="box">
            <h1>User Registration</h1>
            <label>
               <span>Full name</span>
               <input type="text" class="input_text" name="name" id="name"/>
            </label>
             <label>
               <span>Email</span>
               <input type="text" class="input_text" name="email" id="email"/>
            </label>
             <label>
                <span>Subject</span>
                <input type="text" class="input_text" name="subject" id="subject"/>
            </label>
            <label>
                <span>Message</span>
                <textarea class="message" name="feedback" id="feedback"></textarea>
                <input type="button" class="button" value="Submit Form" />
            </label>
            
            
         </div>
</form>

</body>
</html>


PHP


PHP
 require_once "Mail.php";

    $from = "<from.gmail.com>";
    $to = "<to.yahoo.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "<myaccount.gmail.com>";
    $password = "password";

    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password));

    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
     } else {
      echo("<p>Message successfully sent!</p>");
     }

?>
<!-- end of php tag-->
Posted
Updated 14-Sep-11 21:37pm
v4
Comments
LittleYellowBird 15-Sep-11 3:38am    
Not everyone is a sir, so I have added 'or madam' to your question and tidied your text a little at the same time. :)
CPallini 15-Sep-11 4:02am    
OK, Sir, thank you. :-D
LittleYellowBird 15-Sep-11 4:13am    
;P ;P ;P To you! :-D
[no name] 15-Sep-11 4:02am    
Sir, yes sir! :)
LittleYellowBird 15-Sep-11 4:14am    
;P ;P ;P To you as well! :-D

1 solution

Typically HTML code is generated by PHP via the echo statement (you already done it in you code snippet), e.g.:
PHP
echo "<h1>Hi Folks!</h1>"


See, for instance, "PHP Tutorial - Echo"[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900