SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    posting not working using javascript calendar

    i have used java script to add the calendar , now the post is not working when i submitting form its not working but without calender its working fine

    here is coding help me out...
    Code:
    <?php
    
    
    $connection = mysql_connect("localhost","root","password") or die("error connect");
    mysql_select_db("project");
    
    
    
    if (isset($_POST['form_submit'])){
    
    header("location: http://localhost/project/fixed.html");
    
    $fname = $_POST['fname'];
    $doc = $_POST['doc'];
    $cite = $_POST['cit'];
    $apday = $_POST['DV'];
    $aptime = $_POST['time'];
    $mail = $_POST['email'];
    $mob = $_POST['mobi'];
    $ser = $_POST['service'];
    
    $sql = "
        insert into
            fix
        (name, doc, city, appday, apptime, email, mobile, services)
            values
        ('". mysql_real_escape_string($fname) ."'
        ,'".  mysql_real_escape_string($doc) ."'
    	,'".  mysql_real_escape_string($cite) ."'
    	,'".  mysql_real_escape_string($apday) ."'
    	,'".  mysql_real_escape_string($aptime) ."'
    	,'".  mysql_real_escape_string($mail) ."'
    	,'".  mysql_real_escape_string($mob) ."'
    	,'".  mysql_real_escape_string($ser) ."'
    	
    	)
        ";
        
    mysql_query($sql) or die(mysql_error() . ' Query= '. $sql); 
    
    }
    
    
    ?>
    
    
    
    
    
    <!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>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    
    a:link {
    	color: #327685;
    }
    a:visited {
    	color: #327685;
    }
    a:hover {
    	color: #194954;
    }
    a:active {
    	color: #327685;
    }td img {display: block;}
    -->
    </style>
    <script type="text/javascript">
    <!-- Script For Navigation Bar
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    function MM_validateForm() { //v4.0
      if (document.getElementById){
        var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
        for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
          if (val) { nm=val.name; if ((val=val.value)!="") {
            if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
              if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (test!='R') { num = parseFloat(val);
              if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
              if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                min=test.substring(8,p); max=test.substring(p+1);
                if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
        } if (errors) alert('The following error(s) occurred:\n'+errors);
        document.MM_returnValue = (errors == '');
    } }
    //-->
    </script>
    
    
    <script type="text/javascript" language="javascript">
    <!-- Script For Calender
    function HTML(p){
     if(!p){
      /*default*/
      p='A action align alt B background Base bgcolor BIG BLINK BODY border bordercolor bordercolordark bordercolorlight Br cellpadding cellspacing checked color cols colspan compact content dir DIV enctype face FONT FORM H1 H2 H3 H4 H5 H6 HEAD height Hr href hspace HTML I id Img Input lang language leftmargin LI marginheight marginwidth maxlength Meta method name NOSCRIPT noshade nowrap OL onblur onchange onclick onfocus onload onmouseout onmouseover onreset onselect onsubmit onunload OPTION P PRE profile readonly rows rowspan SCRIPT SELECT size SMALL SPAN src start STRIKE STYLE style SUB SUP TABLE target TD TEXTAREA TH TITLE title topmargin TR TT type U UL valign value vspace width wrap'
     };
     String.prototype.write=function(){
      document.write(this);
      return this 
     };
     String.prototype.alert=function(){
      window.alert(this);
      return this 
     };
     String.prototype.status=function(){
      window.status=this;
      return this 
     };
     var x=[
     function(W){var q=String.fromCharCode(34);return ' x='+q+((typeof(W)!='undefined')?W:'x')+q}/*attr*/,
     function(W){return '<x'+((typeof(W)!='undefined')?W:'')+' />'}/*tag*/,
     function(W){return '<x'+((typeof(W)!='undefined')?W:'')+'>'+this+'</'+'x>'}/*container*/,
     function(W){var o='<x'+((typeof(W)!='undefined')?W:'')+' />';return o+this.join(o)}/*tags*/,
     function(W){var o='<x'+((typeof(W)!='undefined')?W:'')+'>';var c='</'+'x>';return o+this.join(c+o)+c}/*containers*/
     ];
     var j=[];
     var f=0;
     var a=p.split(' ');
     var t,u,l;
     for(var i=0;i<a.length;i++){
      t=a[i];
      u=t.toUpperCase();
      l=t.toLowerCase();
      if(t==l){
       /*attr*/
       j[f]='window.'+u+'='+x[0]  
      }
      else if(t==u){
       /*container;containers*/
       j[f]='String.prototype.'+u+'='+x[2]+';Array.prototype.'+u+'='+x[4]  
      }
      else{
       /*tag;tags*/
       j[f]='window.'+u+'='+x[1]+';Array.prototype.'+u+'='+x[3]  
      };
      /*specific*/
      j[f]=j[f].replace(/x/g,l);
      f++ 
     };
     window.status='HTML() bookmarklet library: Copyright (c) 2002-'+(new Date()).getFullYear()+', by Richard Edwards. ['+f+' tag/attrs added] ';
     /*implement!*/
     eval(j.join(';'))
    };
    HTML();
    </script>
    <script type="text/javascript" language="javascript">
    function init(){m='January February March April May June July August September October November December'.split(' ');wd='Su M Tu W Th Fr Sa'.split(' ');lom=[31,28,31,30,31,30,31,31,30,31,30,31];sz=25;js='javascript';fn=[function(F){},function(F){DATE=new Date(F.date.value);if(isNaN(DATE.valueOf())){DATE=new Date()};M=DATE.getMonth();D=DATE.getDate();Y=DATE.getFullYear();lom[1]=28;if((Y%/**/4==0)&&((Y%/**/100>0)||(Y%/**/400==0))){lom[1]++}},function(F){if(D>lom[M]){D=lom[M]};F.date.value=(M<9?'0':'')+(1.0+M)+'/'+(D<10?'0':'')+D+'/'+Y;dv.value=F.date.value;if(opener.Page){opener.document.forms[0][dv.name].value=F.date.value}},function(){F=this.form;fn[1](F);M=this.selectedIndex;fn[2](F);fn[0](F)},function(){F=this.form;fn[1](F);D=this.value;fn[2](F);fn[0](F)},function(){F=this.form;fn[1](F);Y=this.value;fn[2](F);fn[0](F)},function(F){fn[1](F);var f=new Date(Y,M,1);var x=1-(f.getDay());for(var i=0;i<49;i++){F.d[i].value=(i<7?wd[i]:'');F.d[i].onclick=this;};for(var i=1;i<=lom[M];i++){w=Math.floor((i-1)/7);n=7+i-x;F.d[n].value=i;F.d[n].onclick=fn[4];if(i==D){F.d[7+i-x].focus()}};for(var i=0;i<F.m.length;i++){F.m[i].selected=(i==M)};F.m.onchange=fn[3];F.y.value=Y;F.y.onchange=fn[5];F.y.onblur=fn[5];fn[2](F)}];fn[0]=fn[6]};init();function popCal(datevalue){if(!datevalue){dv={name:'Today',value:(new Date())}}else{dv=datevalue};var c=ALIGN('center')+HEIGHT(sz);var h=(m.OPTION().SELECT(NAME('m'))+INPUT(TYPE('text')+SIZE(4)+NAME('y'))+INPUT(TYPE('hidden')+NAME('date')+VALUE(dv.value))).TD(COLSPAN(7)+c);var b=INPUT(TYPE('button')+NAME('d')+STYLE('width:'+sz+';height:'+sz)+WIDTH(sz)+c);var r=[b,b,b,b,b,b,b].TD(WIDTH(sz*7)+c);h=[h,r,r,r,r,r,r,r].TR(c).TABLE(BORDER('0')+CELLSPACING('0')+CELLPADDING('0')+c).FORM(NAME('frm')+ACTION(js+'://'));h+=(init+';init();dv=opener.dv;fn[0](document.forms.frm);').SCRIPT(LANGUAGE(js)+TYPE('text/'+js));window.open('','cal'+(new Date()).valueOf(),'height='+sz*9+',width='+sz*8).document.write(h)};
    
    </script>
    
    </script>
    
    <script type="text/javascript" language="javascript">
    
     function validate_form ( )
    {
        valid = true;
    
        if ( document.tstest.DV.value == "" )
        {
            alert ( "Please fill 'Your Name'" );
            valid = false;
        }
    	
    	 return valid;
    }
    
    </script>
    
    
    
    </head>
    
    <body class="oneColFixCtrHdr">
    
    <div id="container">
      <div id="header"><img src="images/header.jpg" alt="" width="1000" height="179" />
        <!-- end #header -->
      </div>
      <div id="nav"><table border="0" cellpadding="0" cellspacing="0" width="1000">
          <!-- fwtable fwsrc="Untitled" fwpage="Page 1" fwbase="nav.gif" fwstyle="Dreamweaver" fwdocid = "70985465" fwnested="0" -->
          <tr>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="63" height="1" border="0" id="undefined_2" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="71" height="1" border="0" id="undefined_2" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="133" height="1" border="0" id="undefined_2" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="80" height="1" border="0" id="undefined_2" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="84" height="1" border="0" id="undefined_2" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="569" height="1" border="0" id="undefined_2" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="1" height="1" border="0" id="undefined_2" /></td>
          </tr>
          <tr>
            <td><img name="nav_r1_c1" src="images/nav_r1_c1.gif" width="63" height="38" border="0" id="nav_r1_c1" alt="" /></td>
            <td><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav_r1_c2','','images/nav_r1_c2_f2.gif',1);"><img name="nav_r1_c2" src="images/nav_r1_c2.gif" width="71" height="38" border="0" id="nav_r1_c2" alt="" /></a></td>
            <td><a href="finddoctor.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav_r1_c3','','images/nav_r1_c3_f2.gif',1);"><img name="nav_r1_c3" src="images/nav_r1_c3.gif" width="133" height="38" border="0" id="nav_r1_c3" alt="" /></a></td>
            <td><a href="contactus.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav_r1_c4','','images/nav_r1_c4_f2.gif',1);"><img name="nav_r1_c4" src="images/nav_r1_c4.gif" width="80" height="38" border="0" id="nav_r1_c4" alt="" /></a></td>
            <td><a href="aboutus.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav_r1_c5','','images/nav_r1_c5_f2.gif',1);"><img name="nav_r1_c5" src="images/nav_r1_c5.gif" width="84" height="38" border="0" id="nav_r1_c5" alt="" /></a></td>
            <td><img name="nav_r1_c6" src="images/nav_r1_c6.gif" width="569" height="38" border="0" id="nav_r1_c6" alt="" /></td>
            <td><img src="images/spacer.gif" alt="" name="undefined_2" width="1" height="38" border="0" id="undefined_2" /></td>
          </tr>
        </table></div>
      <div id="mainContent">
        <div id="app_form">
          <table width="519" border="0" align="center">
      <tr>
        <td><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="appointment" onsubmit="MM_validateForm('mobi','','RisNum');MM_validateForm('eadd','','RisEmail');return document.MM_returnValue">
        Name: <br /><input name="fname" type="text" onblur="MM_validateForm('eadd','','RisEmail','mobi','','RisNum');return document.MM_returnValue" width="400" />
        <br /></center><br />Email:<br /> <input name="email" type="text" id="eadd" onblur="MM_validateForm('eadd','','RisEmail');return document.MM_returnValue" width="400" />
        <br /><br />Mobile:<br /> <input name="mobi" type="text" id="mobi" width="400" />
        <br /><br />
        
        Doctor:<br /> <select name="doc"  >
      <option value="Primary Care Doctor">Primary Care Doctor</option>
      <option value="Dentist">Dentist</option>
      <option value="Eye Doctor">Eye Doctor</option>
      <option value="Ear-Nose-Throat Doctor">Ear-Nose-Throat Doctor</option>
      <option value="Cardiologist">Cardiologist</option>
      <option value="Physical Thrapist">Physical Thrapist</option>
      <option value="Psychiatrist">Psychiatrist</option>
      </select>
    <br /><br />
    City:<br /> <select name="cit">
      <option value="Khairpur">Khairpur</option>
      <option value="Sukkur">Sukkur</option>
      
    </select>
    <br /><br />
    Appointment Day:<br /><script type="text/javascript" language="javascript">
    (INPUT(NAME("DV")+READONLY())+INPUT(TYPE("button")+VALUE("Calender")+ONCLICK("popCal(this.form.DV)"))).FORM().write();
    </script></CENTER><br><br><br>
    <br /><br />
    Appointment Time:<br /><select name = "time">
      <option value=" 9:00am-10:00am"> 9:00am-10:00am</option>
      <option value="10:00am-11:00am">10:00am-11:00am</option>
      <option value="11:00am-12:00am">11:00am-12:00am</option>
      <option value="12:00am-1:00am"> 12:00am-1:00am</option>
      <option value=" 2:00am-3:00am">  2:00am-3:00am</option>
      <option value=" 3:00am-4:00am">  3:00am-4:00am</option>
      <option value=" 4:00am-5:00am">  4:00am-5:00am</option>
    </select>
    <br /><br />
    Please describe the medical services you require:<br />
    <input name="service" type="text" width="400" height="80" />
    </center>
    <br />
    <input type="hidden" name="action" value="add">
    <input type="submit" value="submit" />
    <input type="hidden" name="form_submit" value="1" />
        </form>    </td>
      </tr>
    </table>
    </div>
    </div>
      <div id="footer">
        <div class="footer_nav"><a href="aboutus.html">Abour Us</a>  -  <a href="contactus.html">Contact Us</a>  -  <a href="Faq.html">Faq's</a>  -  <a href="tou.html">Terms Of Use</a></div>
        <div class="copyright_text">� 2010 Copyright Shah Abdul Latif University. All rights reserved.</div>
        
      <!-- end #footer --></div>
    <!-- end #container --></div>
    </body>
    </html>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    Step 1: Have you echoed out your query and put it through mySQL to make sure it's working?

    Step 2: You're pushing a Location header through that will cause the browser to redirect itself, obscuring any error messages. Why are you doing this, instead of using the form's action attribute?

  3. #3
    SitePoint Member
    Join Date
    May 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    step 1 is already done.
    step 2 i checked without the location header and it still not working and no i dont face any kind of error msgs.... when ever i click to submit thn nothing is happen it still the same as before....

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    just cleaning things up to see better...
    PHP Code:
    <?php
    $connection 
    mysql_connect("localhost","root","password") or die("error connect");
    mysql_select_db("project");

    if (isset(
    $_POST['form_submit'])){
    $fname $_POST['fname'];
    $doc $_POST['doc'];
    $cite $_POST['cit'];
    $apday $_POST['DV'];
    $aptime $_POST['time'];
    $mail $_POST['email'];
    $mob $_POST['mobi'];
    $ser $_POST['service'];

    $sql "
        insert into
            fix
        (name, doc, city, appday, apptime, email, mobile, services)
            values
        ('"
    mysql_real_escape_string($fname) ."'
        ,'"
    .  mysql_real_escape_string($doc) ."'
        ,'"
    .  mysql_real_escape_string($cite) ."'
        ,'"
    .  mysql_real_escape_string($apday) ."'
        ,'"
    .  mysql_real_escape_string($aptime) ."'
        ,'"
    .  mysql_real_escape_string($mail) ."'
        ,'"
    .  mysql_real_escape_string($mob) ."'
        ,'"
    .  mysql_real_escape_string($ser) ."'
        
        )
        "
    ;
        
    mysql_query($sql) or die(mysql_error() . ' Query= '$sql); 

    }
    ?>

        <td><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="appointment" onsubmit="MM_validateForm('mobi','','RisNum');MM_validateForm('eadd','','RisEmail');return document.MM_returnValue">
        Name: <br /><input name="fname" type="text" onblur="MM_validateForm('eadd','','RisEmail','mobi','','RisNum');return document.MM_returnValue" width="400" />
        <br /></center><br />Email:<br /> <input name="email" type="text" id="eadd" onblur="MM_validateForm('eadd','','RisEmail');return document.MM_returnValue" width="400" />
        <br /><br />Mobile:<br /> <input name="mobi" type="text" id="mobi" width="400" />
        <br /><br />
        
        Doctor:<br /> <select name="doc"  >
      <option value="Primary Care Doctor">Primary Care Doctor</option>
      <option value="Dentist">Dentist</option>
      <option value="Eye Doctor">Eye Doctor</option>
      <option value="Ear-Nose-Throat Doctor">Ear-Nose-Throat Doctor</option>
      <option value="Cardiologist">Cardiologist</option>
      <option value="Physical Thrapist">Physical Thrapist</option>
      <option value="Psychiatrist">Psychiatrist</option>
      </select>
    <br /><br />
    City:<br /> <select name="cit">
      <option value="Khairpur">Khairpur</option>
      <option value="Sukkur">Sukkur</option>
      
    </select>
    <br /><br />
    Appointment Day:<br /><script type="text/javascript" language="javascript">
    (INPUT(NAME("DV")+READONLY())+INPUT(TYPE("button")+VALUE("Calender")+ONCLICK("popCal(this.form.DV)"))).FORM().write();
    </script></CENTER><br><br><br>
    <br /><br />
    Appointment Time:<br /><select name = "time">
      <option value=" 9:00am-10:00am"> 9:00am-10:00am</option>
      <option value="10:00am-11:00am">10:00am-11:00am</option>
      <option value="11:00am-12:00am">11:00am-12:00am</option>
      <option value="12:00am-1:00am"> 12:00am-1:00am</option>
      <option value=" 2:00am-3:00am">  2:00am-3:00am</option>
      <option value=" 3:00am-4:00am">  3:00am-4:00am</option>
      <option value=" 4:00am-5:00am">  4:00am-5:00am</option>
    </select>
    <br /><br />
    Please describe the medical services you require:<br />
    <input name="service" type="text" width="400" height="80" />
    </center>
    <br />
    <input type="hidden" name="action" value="add">
    <input type="submit" value="submit" />
    <input type="hidden" name="form_submit" value="1" />
        </form>

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    I dont see anything wrong, but some of the javascript eludes me (redefining the write function? not generally a good idea in my mind....)

    Your PHP is fine; thus this question should be placed in the javascript forum where someone more knowledgable than me can answer it..


Bookmarks

Posting Permissions

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