View Full Version : Storing forum details in mysql

07-05-2005, 06:54 PM
Ok, I made this script for my hosting company as an order forum. It gets the basic details off the user and gives them a paypal button, but I was wondering if anyone knew how I could take the details, store them into mysql and have a page so that me or other admins can come to, and view orders.

Thanks in advance:

HTML Order page:

<meta http-equiv="Content-Language" content="en-gb">

//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var checkobj

function agreesubmit(el){
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
alert("Please read/accept terms to submit form")
return false

<script type="text/javascript">

* Switch Content script- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

var contractsymbol='- ' //HTML for contract symbol. For image, use: <img src="whatever.gif">
var expandsymbol='+ ' //HTML for expand symbol.

if (document.getElementById){
document.write('<style type="text/css">')

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
return temparray

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol

function revivecontent(){
for (i=0; i<selectedComponents.length-1; i++)

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
return returnvalue;

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
return selectedItem
return ""

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")


function do_onload(){
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0"
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
if (ccollect.length>0 && statecollect.length>0)

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)

if (enablepersist=="on" && document.getElementById)

<style type="text/css">

padding: 2px;
border:1px solid black;
font:normal 12px Verdana;

<script type="text/javascript">

* Fixed ToolTip script- Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code

var tipwidth='150px' //default tooltip width
var tipbgcolor='lightyellow' //tooltip bgcolor
var disappeardelay=250 //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="0px" //horizontal offset of tooltip from anchor link
var horizontal_offset="-3px" //horizontal offset of tooltip from anchor link

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
return totaloffset;

function showhide(obj, e, visible, hidden, tipwidth){
if (ie4||ns6)
if (tipwidth!=""){
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
else if (e.type=="click")

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
return edgeoffset

function fixedtooltip(menucontents, obj, e, tipwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)

function delayhidetip(){
if (ie4||ns6)

function clearhidetip(){
if (typeof delayhide!="undefined")


<form method="POST" name="order" action="buyshared.php">
<table border="0" width="530" id="table2">
<td width="191">Name:</td>
<td width="310"> <input type="text" name="name" size="20"></td>
<td width="15">
<img onMouseover="fixedtooltip('Please enter your name for our records only. This will not be shared with third part companies and will be deleted if you ever choose to leave us.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<td width="191">Email Address</td>
<td width="310"> <input type="text" name="email" size="20"></td>
<td width="15">
<img onMouseover="fixedtooltip('Your email address will be used to contact you for updates and any news that we feel you may be intrested in. Your account details will also be sent here.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<td width="191">Package:</td>
<td width="310"> <select size="1" name="package"><option value="Package One">Package One</option>
<option value="Package Two">Package Two</option>
<option value="Package Three">Package Three</option>
<option value="Package Four">Package Four</option>
<option value="Package Five">Package Five</option>
<option value="Package Six">Package Six</option>
<option value="Package Seven">Package Seven</option>
<option value="Package Eight">Package Eight</option>
<option value="Package Nine">Package Nine</option>
<option value="Package Ten">Package Ten</option>
<option value="Unmetered Plan">Unmetered Plan</option>
<td width="15">
<img onMouseover="fixedtooltip('Please select the package you wish to purchase. If you wish to review the prices again, please select ethier shared, or reseller on the left menu.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<td width="191">Do you already have a domain?</td>
<td width="310"> <label for="yes">Yes</label><input type="radio" id="yes" onClick="javascript:sweeptoggle('contract')" value="yes" checked name="gotdomain"> <label for="no">
No</label><input type="radio" onClick="javascript:sweeptoggle('expand')" id="no" name="gotdomain" value="no">
<div id="sc3" class="switchcontent">
<table border="1px" id="table1" cellspacing="0" cellpadding="0" bordercolorlight="#FF0000" bordercolordark="#FF0000">
<td bgcolor="#FF5555" align="center"><font color="#FFFFFF"><b>Unfortunately you need a
domain to continue with the process. To purchase a domain,
please go to our purchase domain section, located on the left.</b></font></td>
<td width="15">
<img onMouseover="fixedtooltip('If you already have a domain then we will email you and tell you the details you need to configure it. If you dont, then we can setup one for you. Click no for more details.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<td width="191">Domain name:</td>
<td width="310">http://www.
<input type="text" name="domain" size="20" value="yourdomain"> .
<select size="1" name="ext">
<option value="biz">biz</option>
<option value="com">com</option>
<option value="co.uk">co.uk</option>
<option value="info">info</option>
<option value="name">name</option>
<option value="net">net</option>
<option value="me.uk">me.uk</option>
<option value="org">org</option>
<option value="org.uk">org.uk</option>
<option value="tv">tv</option>
<option value="us">us</option>
<option value="ws">ws</option>
<td width="15">
<img onMouseover="fixedtooltip('Please enter the domain name you have / want. Name can <b>ONLY</b> contain letters, numbers and -. No spaces are alloued.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<td width="191">Desired Password:</td>
<td width="310"> <input type="password" name="password" size="20"></td>
<td width="15">
<img onMouseover="fixedtooltip('Please choose a password for your account, again only letters and numbers, no symbols or spaces. if you leave this box blank, the computer will randomly select one for you.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<td width="191">Confirm Password</td>
<td width="310"> <input type="password" name="passwordconfirm" size="20"></td>
<td width="15">
<img onMouseover="fixedtooltip('Please enter the password above here again to confirm. Leave blank for a random password.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></td>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"> <b>I
have read and agree to the TOS/AUP of PlatinumHost. TOS/AUP can be found
<a target="_blank" href="index.php?name=TOS&r=n">Here</a>! </b>
<img onMouseover="fixedtooltip('You must agree to our terms before useing our products. Click the link on the left to view the terms.', this, event, '200px')" onMouseout="delayhidetip()" border="0" src="images/i.png" width="15" height="15"></p>
//change two names below to your form's names
<p><input type="Submit" value="Submit!" disabled><input type="reset" value="Reset" name="B2"></p>

PHP Page:

//Make varibles
$package = $_POST['package'];
$domain = $_POST['domain'];
$ext = $_POST['ext'];
$password = $_POST['password'];
$passwordconfirm = $_POST['passwordconfirm'];
$packageprice = 0;
$name = $_POST['name'];
$email = $_POST['email'];
$agreecheck = $_POST['agreecheck'];

//Random password function
function createRandomPassword() {
$chars = "AaBbCcDdEeFfGgHhJjKkLMmNnPpQqRrSsTtUuVvXxYyZz23456789";
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
return $pass;

//Check Passwords are the same
if ($password != $passwordconfirm) {
echo "Password was not the same, Please click back and try again.";
//If the password field was left blank, then genarate one
} elseif ($password == "") {
$password = createRandomPassword();

//Work out package price
if ($package == "Package One") {
$packageprice = 1.99;
} elseif ($package == "Package Two") {
$packageprice = 2.99;
} elseif ($package == "Package Three") {
$packageprice = 3.99;
} elseif ($package == "Package Four") {
$packageprice = 4.99;
} elseif ($package == "Package Five") {
$packageprice = 5.99;
} elseif ($package == "Package Six") {
$packageprice = 6.99;
} elseif ($package == "Package Seven") {
$packageprice = 7.99;
} elseif ($package == "Package Eight") {
$packageprice = 8.99;
} elseif ($package == "Package Nine") {
$packageprice = 9.99;
} elseif ($package == "Package Ten") {
$packageprice = 10.99;
} elseif ($package == "Unmetered Plan") {
$packageprice = 19.99;

echo " <table border=\"0\" width=\"361\" id=\"table2\">
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Name:</b></font></td>
<td width=\"240\"> $name</td>
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Email Address</b></font></td>
<td width=\"240\"> $email</td>
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Package:</b></font></td>
<td width=\"240\"> $package</td>
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Domain name:</b></font></td>
<td width=\"240\">http://www.$domain.$ext</td>
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Password:</b></font></td>
<td width=\"240\">$password</td>
<td width=\"111\"><font size=\"1\">&nbsp;</font></td>
<td width=\"240\"><font size=\"1\">&nbsp;</font></td>
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Package Price</b></font></td>
<td width=\"240\">$packageprice per month</td>
<td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Setup Fee</b></font></td>
<td width=\"240\">0.00</td>
<td width=\"111\" bgcolor=\"#3399FF\"><b><font color=\"#FFFFFF\">Total
<td width=\"240\">$packageprice per month</td>
<p>If all this information is correct, please press the paypal button below
and continue with payment. Once payment has been recived, you will get your
account settings by email from a member of staff.</p>

<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">
<table><tr><td><input type=\"hidden\" name=\"on0\" value=\"Domain\">Domain</td><td><input type=\"text\" name=\"os0\" maxlength=\"200\"></td></tr></table><input type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/x-click-but20.gif\" border=\"0\" name=\"submit\" alt=\"Make payments with PayPal - it's fast, free and secure!\">
<input type=\"hidden\" name=\"cmd\" value=\"_xclick-subscriptions\">
<input type=\"hidden\" name=\"business\" value=\"paypal@platinumhost.co.uk\">
<input type=\"hidden\" name=\"item_name\" value=\"$package\">
<input type=\"hidden\" name=\"item_number\" value=\"55555\">
<input type=\"hidden\" name=\"no_shipping\" value=\"1\">
<input type=\"hidden\" name=\"return\" value=\"http://www.platinumhost.co.uk/index.php?name=Success\">
<input type=\"hidden\" name=\"cancel_return\" value=\"http://www.platinumhost.co.uk/index.php?name=Canceled\">
<input type=\"hidden\" name=\"no_note\" value=\"1\">
<input type=\"hidden\" name=\"currency_code\" value=\"GBP\">
<input type=\"hidden\" name=\"a3\" value=\"$packageprice\">
<input type=\"hidden\" name=\"p3\" value=\"1\">
<input type=\"hidden\" name=\"t3\" value=\"M\">
<input type=\"hidden\" name=\"src\" value=\"1\">
<input type=\"hidden\" name=\"sra\" value=\"1\">

P.S. I'm not great with php and know nothing bout mysql, so, talk english please :)

Thanks for your time and effort ;) :thumbsup:

07-06-2005, 02:33 AM
you're going to have to invest some time to learn at least the basics of PHP and MySQL, becasue no one here is likely to write this code for you...that being said, this is easily accomplished with some simple PHP and SQL queries...So, the good new is, once you know the basics, you should have no difficulty putting your order form page together.... ;)

and if you have questions along the way, I encourage you to come back here for help.... :thumbsup:

07-06-2005, 11:45 AM
I have tried to learn it I just can't get my head around it. I dont understand tables etc. It's too hard :(

07-06-2005, 12:44 PM
It might seem difficult at first but if you run through some of the simpler tutorials online you will soon have the basics and once you've mastered those it just gets easier, and like chump said, there are always people here willing to lend a hand if you get stuck.

If you have a job that needs doing ASAP and you don't have the time to invest to do it yourself then that's what the paid work offer forums are for. For a reasonable fee someone will be able to do what you want, I'm sure :)