Your Code Here...
Otherwise nice idea, but this section is dead, nobody seems to care about good old web dev 


DD <3<?php
session_start();
$_SESSION['token']=md5(rand()); // We add this so we get "protected" from bots
?>
<html>
<head>
<title>My contact form</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="contactform.js"></script>
</head>
<body>
<div id="form">
<p>Name:<input type="text" id="name"></p>
<p>Email:<input type="text" id="email"></p>
<p>Message:<textarea id="message"></textarea></p>
<input type="hidden" value="<?php echo $_SESSION['token']; ?>" id="token">
<a href="#" id="send">Send</a>
</div>
<div id="loading" style="display: none;">
<img src="loading.gif">
</div>
<div id="mess" style="display: none;">
</div>
</body>
</html>
$(document).ready(function(){
var sending = false;
// we define the var "sending" so we can check that the user doesnt click the send button many times.
var showmess = false;
// this is to hide the "mess" div
$('#send').click(function(){
// when any item with the id send is clicked;
if(sending==false){
if(showmess){
$('#mess').slideToggle();
// we hide it.
}
// we check that the "form" isnt beeing "submited"
sending = true;
var name = $('#name').val();
var email = $('#email').val();
var message = $('#message').val();
var token = $('#token').val();
// we take the vals from the inputs (also, the token so we can verify it on contactform.php)
var send = jQuery.parseJSON('{"name":"'+name+'","email":"'+email+'","message":"'+message+'","token":"'+token+'"}');
// "prepare" the Json
$.ajax({
type: "POST",
url: "contactform.php",
data: send,
dataType: "json",
beforeSend: function(obj){
// before send, we will want to slide the div with ID form, and show the loading one (wich is actually hidden)
$('#form').slideToggle();
$('#loading').slideToggle();
},
success: function(json){
// we check here what we got from the server side, and depending on what happened, what we will show.
$('#loading').slideToggle();
if(json.status==1){
$('#form').html('Message sent.');
$('#form').slideToggle();
}else{
showmess = true;
$('#form').slideToggle();
sending = false;
$('#mess').html(json.message);
$('#mess').slideToggle();
}
}
});
}
});
});
<?php
// we start the session and get the headers for the "return"
session_start();
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 10 Jul 2000 02:00:00 GMT');
header('Content-type: application/json');
// we add this, as im running this script on my localhost, it takes ms to load and i cant see the js effects
sleep(1);
if(!isset($_SESSION['token'])){
// if token isnt there, then.. probably, a bot, or someone trying to play around, we show him what we got!
die();
}else{
// if not.. then we check that the token we got from the html, is the same that we got in the session
$token = isset($_POST['token'])? $_POST['token'] : '';
if($token != $_SESSION['token']){
// if its not the same, then we kick him back.
$return['status'] = 0;
$return['message'] = 'Invalid token.';
echo json_encode($return);
die();
}else{
// but if not, we start getting the variables via POST (the json did this possible)
$name = isset($_POST['name'])? trim($_POST['name']) : '';
$phone = isset($_POST['phone'])? trim($_POST['phone']) : '';
$email = isset($_POST['email'])? trim($_POST['email']) : '';
$message = isset($_POST['message'])? trim($_POST['message']) : '';
// we get a $return variable, that will be an array (json.message on the js is $return['message'])
$return = array();
$return['message'] = '';
$return['status'] = 0;
// we make some validations
if(!preg_match('/^[a-zA-ZáéíóúÁÉÍÓÚÀÈÌÒÙàèìòù ]{2,20}$/', $name)){
$return['message'].='Name\'s not valid!.<br>';
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$return['message'].='Invalid email.<br>';
}
if(strlen($message)<10 || strlen($message)>500){
$return['message'].='Invalid message.';
}
// if $return['message'] == '', means that theres no errors; we send the message
if($return['message']==''){
// $to would be changed by the email u want the mail to head.
$to = 'my@Email.com';
// well.. the rest of it.. read about mail() function lol.
$title = 'New message';
$mess = '<html><head></head><body>' .$name . ' sent a message, the email is: '.$email.'.'.'<br>Message was:<br>'.$message.'</body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: w.e' . "\r\n" . 'Reply-To: ' . $email . "\r\n";
@Mail($to,$title,$mess,$headers);
$return['status'] = 1;
}
// and now, we do an echo with the encoded json of $result, then die.
echo json_encode($return);
die();
}
}
)
<?php
// Calculator Script v1
// Copyright (C) 2007 RageD
// Define to make this all one document
$page = $_GET['page'];
// Defining the "calc" class
class calc {
var $number1;
var $number2;
function add($number1,$number2)
{
$result =$number1 + $number2;
echo("The sum of $number1 and $number2 is $result<br><br>");
echo("$number1 + $number2 = $result");
exit;
}
function subtract($number1,$number2)
{
$result =$number1 - $number2;
echo("The difference of $number1 and $number2 is $result<br><br>");
echo("$number1 - $number2 = $result");
exit;
}
function divide($number1,$number2)
{
$result =$number1 / $number2;
echo("$number1 divided by $number2 is $result<br><br>");
echo("$number1 ÷ $number2 = $result");
exit;
}
function multiply($number1,$number2)
{
$result =$number1 * $number2;
echo("The product of $number1 and $number2 is $result<br><br>");
echo("$number1 x $number2 = $result");
exit;
}
}
$calc = new calc();
?>
<TITLE>PHP Calculator v1</TITLE>
<form name="calc" action="?page=calc" method="POST">
Number 1: <input type=text name=value1><br>
Number 2: <input type=text name=value2><br>
Operation: <input type=radio name=oper value="add">Addition <input type=radio name=oper value="subtract">Subtraction <input type=radio name=oper value="divide">Division <input type=radio name=oper value="multiply">Multiplication</input><br>
<input type=submit value="Calculate">
</form>
<?php
if($page == "calc"){
$number1 = $_POST['value1'];
$number2 = $_POST['value2'];
$oper = $_POST['oper'];
if(!$number1){
echo("You must enter number 1!");
exit;
}
if(!$number2){
echo("You must enter number 2!");
exit;
}
if(!$oper){
echo("You must select an operation to do with the numbers!");
exit;
}
if(!eregi("[0-9]", $number1)){
echo("Number 1 MUST be a number!");
exit;
}
if(!eregi("[0-9]", $number2)){
echo("Number 2 MUST be a number!");
exit;
}
if($oper == "add"){
$calc->add($number1,$number2);
}
if($oper == "subtract"){
$calc->subtract($number1,$number2);
}
if($oper == "divide"){
$calc->divide($number1,$number2);
}
if($oper == "multiply"){
$calc->multiply($number1,$number2);
}
}
?>
![=]](/forum/images/emotions/=].gif)
CREATE TABLE `test_mysql` ( `id` int(4) NOT NULL auto_increment, `name` varchar(65) NOT NULL default '', `lastname` varchar(65) NOT NULL default '', `email` varchar(65) NOT NULL default '', `ip` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=0 ;

<html> <head> </head> <body> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="insert_ac.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Lastname</td> <td>:</td> <td><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </td> </tr> </table> </body> </html>
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="test_mysql"; // Table name
//test
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$name=$_POST['name'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$ip=$_SERVER['REMOTE_ADDR'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(name, lastname, email, ip)VALUES('$name', '$lastname', '$email', '$ip')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Redirecting - Please wait...";
}
else {
echo "ERROR";
}
// close connection
mysql_close();
?>
![=]](/forum/images/emotions/=].gif)
<form action="?generate" method="post">
<!-- Input Field for the minimum char. -->
Minimum Char:
<input id="int1" name="int1" type="text" /><br />
<!-- Input Field for the maximum char. -->
Maximum Char:
<input id="int2" name="int2" type="text" /><br />
<input type="submit" value="Generate" />
</form>
<?php
//checking if form has been submitted
if(isset($_REQUEST["generate"])) {
//setting variables.
$int1 = $_REQUEST["int1"];
$int2 = $_REQUEST["int2"];
//making sure that there are only numbers
$int1 = floatval($int1);
$int2 = floatval($int2);
//checking if min int is bigger than max int
if($int1 >= $int2) {
echo "The Minimum char has to be lower than the Maximum char (Make sure that there are no letters).";
}
else {
//Will Print out a random number between int1 and int2
echo "Your random Number: " . rand($int1, $int2);
}
}
?>
<?php
class ArrayToXML {
private $xml;
private $root;
public function parseXML($array, $api) {
$this->root = new SimpleXMLElement('<?xml version="1.0"?><' . $api . '></' . $api . '>');
$this->toXML($array,$this->root);
}
public function toXML($array, $root) {
foreach($array as $key => $value) {
if(is_array($value)) {
if(!is_numeric($key)){
$subnode = $this->root->addChild($key);
$this->toXML($value, $subnode);
}
else{
$this->toXML($value, $this->root);
}
}
else {
$this->root->addChild($key,$value);
}
}
}
public function render() {
return $this->root->asXML();
}
}
<?php
$array = array('status' => 1, 'message' => 'success!');
$xml = new ArrayToXML;
$xml->parseXML($array, 'result');
return $xml->render();
?>