5 Replies - 1896 Views - Last Post: 05 February 2010 - 03:00 AM Rate Topic: -----

#1 lazyserv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-January 10

How to edit the php code

Post icon  Posted 16 January 2010 - 11:52 PM

Hi just know basic html code and i get this code from a website (sorry cant credit them because i forgotten the site link)

now i had edit the html part, but the php part i dont know how to edit because i dont know php code totally.

HTML :
<form method="post" action="contact.php"> 
<table width="400" align=center bgcolor=#ffffff> 
<tr><td width="150"><p>Division:</p></td><td width="250"><p><input type="checkbox" name="sendto" value="support@vivacenetwork.co.cc" checked="checked" />Support</input></p></td></tr> 
<tr><td><p><font color=red>*</font> Name:</p></td><td><input size=30 name="Name"></td></tr> 
<tr><td><p><font color=red>*</font> Contact No.:</p></td><td><input size=30 name="Contact No."></td></tr>
<tr><td><p><font color=red>*</font> Mailing Address:</p></td><td><textarea name="Mailing Address" rows=3 cols=30></textarea></td></tr> 
<tr><td><p><font color=red>*</font> Email:</p></td><td><input size=30 name="Email"></td></tr>
<tr><td><p><font color=red>*</font> Item Code:</p></td><td><select><option>Item 1</option><option>Item 2</option></select> 
</td></tr> 
<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"> <input type=reset value="Reset" /></td></tr> 
<tr><td colspan=2 align=center><p><small>A <font color=red>*</font> indicates a field is required</small></p></td></tr> 
</table> 
</form>
</body>


pHp :
<?php  
$to = $_REQUEST['sendto'];  
$from = $_REQUEST['Email'];  
$name = $_REQUEST['Name'];  
$headers = "From: $from";  
$subject = "Website Support";  

$fields = array();  
$fields{"Name"} = "Name";  
$fields{"Email"} = "Email";  
$fields{"Message"} = "Message";  

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }  

$headers2 = "From: noreply@vivacenetwork.co.cc";  
$subject2 = "Thank you for contacting us";  
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our forum at http://forum.vivacenetwork.co.cc"; 

if($from == '') {print "You have not entered an email, please go back and try again";}  
else {  
if($name == '') {print "You have not entered a name, please go back and try again";}  
else {  
$send = mail($to, $subject, $body, $headers);  
$send2 = mail($from, $subject2, $autoreply, $headers2);  
if($send)  
{header( "Location: http://vivacenetwork.co.cc/thankyou.htm" );}  
else  
{print "We encountered an error sending your mail, please notify support@vivacenetwork.co.cc"; }  
} 
} 
?>


i hope some one can give me some example so that i can make it work as a order form. Thanks alot for thoose who reading and helping me.

P/S : Sorry if I got any broken English.

Is This A Good Question/Topic? 0
  • +

Replies To: How to edit the php code

#2 nick1200  Icon User is offline

  • Php Coder
  • member icon

Reputation: -19
  • View blog
  • Posts: 922
  • Joined: 21-March 09

Re: How to edit the php code

Posted 17 January 2010 - 07:34 AM

put the php on top of the page and html under it
make sure there is a if post in the html
and put it all in a notpad save has test.php and your done

php then html
Was This Post Helpful? 0
  • +
  • -

#3 bharath21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 05-January 10

Re: How to edit the php code

Posted 01 February 2010 - 11:24 AM

Hi,

Quick questions:
1.Is the php code a separate file or a part of HTML file.

2.The array has been delcared with {}. This is incorrect please refer the php user guide link below:
http://php.net/manua...types.array.php

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

#4 Auzzie  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 43
  • View blog
  • Posts: 573
  • Joined: 20-January 09

Re: How to edit the php code

Posted 01 February 2010 - 04:23 PM

First off it should be () not {} surrounding array key's. Secondly you will need to sanitize your input otherwise you are letting your site become liable for hacking attempts.
Next problem is you need to indent your code, also rather then just finding scripts on the net that you don't understand, why don't you google for php tutorials so you can learn. It will benefit you so much in the long run.
Was This Post Helpful? 0
  • +
  • -

#5 osiware  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-February 10

Re: How to edit the php code

Posted 04 February 2010 - 04:47 PM

look in www.php.net to php language also www.w3schools.com for php and html code is the good begining.

This post has been edited by osiware: 04 February 2010 - 04:53 PM

Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is offline

  • Head MFIC
  • member icon

Reputation: 5070
  • View blog
  • Posts: 26,456
  • Joined: 10-May 07

Re: How to edit the php code

Posted 05 February 2010 - 03:00 AM

osiware, why send someone to another site? We have tons of PHP Tutorials & Snippets here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1