Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post

    Storing forum details in mysql

    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:
    PHP Code:
    <head>
    <
    meta http-equiv="Content-Language" content="en-gb">
    <
    script>

    //"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){
    checkobj=el
    if (document.all||document.getElementById){
    for (
    i=0;i<checkobj.form.length;i++){ //hunt down submit button
    var tempobj=checkobj.form.elements[i]
    if(
    tempobj.type.toLowerCase()=="submit")
    tempobj.disabled=!checkobj.checked
    }
    }
    }

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

    </script>
    <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">')
    document.write('.switchcontent{display:none;}')
    document.write('</style>')
    }

    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)
    temparray[inc++]=rootobj[i]
    }
    return temparray
    }

    function sweeptoggle(ec){
    var thestate=(ec=="expand")? "block" : "none"
    var inc=0
    while (ccollect[inc]){
    ccollect[inc].style.display=thestate
    inc++
    }
    revivestatus()
    }


    function contractcontent(omit){
    var inc=0
    while (ccollect[inc]){
    if (ccollect[inc].id!=omit)
    ccollect[inc].style.display="none"
    inc++
    }
    }

    function expandcontent(curobj, cid){
    var spantags=curobj.getElementsByTagName("SPAN")
    var showstateobj=getElementbyClass(spantags, "showstate")
    if (ccollect.length>0){
    if (collapseprevious=="yes")
    contractcontent(cid)
    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
    else
    revivestatus()
    }
    }
    }

    function revivecontent(){
    contractcontent("omitnothing")
    selectedItem=getselectedItem()
    selectedComponents=selectedItem.split("|")
    for (i=0; i<selectedComponents.length-1; i++)
    document.getElementById(selectedComponents[i]).style.display="block"
    }

    function revivestatus(){
    var inc=0
    while (statecollect[inc]){
    if (ccollect[inc].style.display=="block")
    statecollect[inc].innerHTML=contractsymbol
    else
    statecollect[inc].innerHTML=expandsymbol
    inc++
    }
    }

    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) != ""){
    selectedItem=get_cookie(window.location.pathname)
    return selectedItem
    }
    else
    return ""
    }

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

    document.cookie=window.location.pathname+"="+selectedItem
    }

    function do_onload(){
    uniqueidn=window.location.pathname+"firsttimeload"
    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)
    revivecontent()
    }
    if (ccollect.length>0 && statecollect.length>0)
    revivestatus()
    }

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

    if (enablepersist=="on" && document.getElementById)
    window.onunload=saveswitchstate

    </script>
    <style type="text/css">

    #fixedtipdiv{
    position:absolute;
    padding: 2px;
    border:1px solid black;
    font:normal 12px Verdana;
    line-height:18px;
    z-index:100;
    }

    </style>
    </head>
    <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;
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }


    function showhide(obj, e, visible, hidden, tipwidth){
    if (ie4||ns6)
    dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (tipwidth!=""){
    dropmenuobj.widthobj=dropmenuobj.style
    dropmenuobj.widthobj.width=tipwidth
    }
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
    obj.visibility=visible
    else if (e.type=="click")
    obj.visibility=hidden
    }

    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
    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
    edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
    }
    else{
    var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
    edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
    }
    return edgeoffset
    }

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

    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)
    dropmenuobj.style.visibility="hidden"
    }
    }

    function delayhidetip(){
    if (ie4||ns6)
    delayhide=setTimeout("hidetip()",disappeardelay)
    }

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

    </script>

    <form method="POST" name="order" action="buyshared.php">
        <table border="0" width="530" id="table2">
            <tr>
                <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>
            </tr>
            <tr>
                <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>
            </tr>
            <tr>
                <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>
        </select></td>
                <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>
            </tr>
            <tr>
                <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">
                <tr>
                    <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>
                </tr>
            </table>
        </div></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>
            </tr>
            <tr>
                <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>
        </select></td>
                <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>
            </tr>
            <tr>
                <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>
            </tr>
            <tr>
                <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>
            </tr>
        </table>
        <p>
        <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>
    <script>
    //change two names below to your form's names
    document.forms.order.agreecheck.checked=false
    </script>    
        <p><input type="Submit" value="Submit!" disabled><input type="reset" value="Reset" name="B2"></p>
    </form> 
    PHP Page:
    PHP Code:
    <?
    //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";
        
    srand((double)microtime()*1000000);
        
    $i 0;
        
    $pass '' ;
        while (
    $i <= 7) {
            
    $num rand() % 33;
            
    $tmp substr($chars$num1);
            
    $pass $pass $tmp;
            
    $i++;
        }
        return 
    $pass;
    }

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

    //Invoice
        //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\">
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Name:</b></font></td>
                <td width=\"240\"> $name</td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Email Address</b></font></td>
                <td width=\"240\"> $email</td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Package:</b></font></td>
                <td width=\"240\"> $package</td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Domain name:</b></font></td>
                <td width=\"240\">http://www.$domain.$ext</td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Password:</b></font></td>
                <td width=\"240\">$password</td>
            </tr>
            <tr>
                <td width=\"111\"><font size=\"1\">&nbsp;</font></td>
                <td width=\"240\"><font size=\"1\">&nbsp;</font></td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Package Price</b></font></td>
                <td width=\"240\">$packageprice per month</td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><font color=\"#FFFFFF\"><b>Setup Fee</b></font></td>
                <td width=\"240\">0.00</td>
            </tr>
            <tr>
                <td width=\"111\" bgcolor=\"#3399FF\"><b><font color=\"#FFFFFF\">Total 
                Cost</font></b></td>
                <td width=\"240\">$packageprice per month</td>
            </tr>
        </table>
        <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\">
    </form>"
    ;
    ?>
    P.S. I'm not great with php and know nothing bout mysql, so, talk english please

    Thanks for your time and effort

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,744
    Thanks
    18
    Thanked 155 Times in 146 Posts
    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....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    I have tried to learn it I just can't get my head around it. I dont understand tables etc. It's too hard

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •