Jump to content

PHP_CHILD

Members
  • Posts

    30
  • Joined

  • Last visited

PHP_CHILD's Achievements

Member

Member (2/5)

0

Reputation

  1. i have a many links like these <a href="www.ex.com/action.php?me=1">member1</a> i wanted to get this by ajax get method.. <script> $("a.member").click(function(e){ $.ajax({ type: "GET", url: "action.php?me=", data: "me=" + me, success: function(data){ alert(data); } }); return false; e.preventDefault(); }); </script> i know somethin wrong here..am in re.php..i am using this to navigate to action.php file.. Any help appreciated..
  2. Before asking any questions,i would like to thank phpfreaks forum for answering my questions.. Really helpful, thanks again.. i have this tabbed menu.. it worked nicee.. but when i add input submit at last, it is not shown,pls help.. might be css issue, tried that some things, but didn't work, pls help... css <style> ul.tabs { margin: 0; padding: 0; float: left; list-style: none; height: 32px; /*--Set height of tabs--*/ border-bottom: 1px solid #999; border-left: 1px solid #999; width: 100%; } ul.tabs li { float: left; margin: 0; padding: 0; height: 31px; /*--Subtract 1px from the height of the unordered list--*/ line-height: 31px; /*--Vertically aligns the text within the tab--*/ border: 1px solid #999; border-left: none; margin-bottom: -1px; /*--Pull the list item down 1px--*/ overflow: hidden; position: relative; background: #e0e0e0; } ul.tabs li a { text-decoration: none; color: #000; display: block; font-size: 1.2em; padding: 0 20px; border: 1px solid #fff; /*--Gives the bevel look with a 1px white border inside the list item--*/ outline: none; } ul.tabs li a:hover { background: #ccc; } html ul.tabs li.active, html ul.tabs li.active a:hover { /*--Makes sure that the active tab does not listen to the hover properties--*/ background: #fff; border-bottom: 1px solid #fff; /*--Makes the active tab look like it's connected with its content--*/ } .tab_container { border: 1px solid #999; border-top: none; //overflow: hidden; clear: both; float: left; width: 100%; background: #fff; height:auto; } .tab_content { padding: 20px; font-size: 1.2em; color:#333; height:auto; } * { margin:0; // disable for button padding:0; // disable for button border:0; // disable for button } </style> script for tab <script type="text/javascript"> $(document).ready(function() { //Default Action $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active content return false; }); }); </script> <ul class="tabs"> <li><a href="#tab1">First tab</a></li> <li><a href="#tab2">Second tab</a></li> </ul> <div class="tab_container"> <div id="tab1" class="tab_content"> Content of the first tab </div> <div id="tab2" class="tab_content"> Content </div> when i used the content area to display my form, it was displayed.. but then when i included the submit button it is not seen.. but then when i use only submit button (no form content)it is displayed. what am doin wrong..pls help..
  3. got the answer..i was getting trying to get the value of those fields(getelementof) via javascript.. deleted those two lines...
  4. hello all, am beginning to use jquery.. i am using the code online.. all works fine but when i remove 2 lines it fails.. these two lines are simple input fields.. plss help..no idea what am doing wrong.. <!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" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" /> <title>Example Ajax and Form</title> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> <script> $(function() { $( "#datepicker" ).datepicker(); }); </script> <script type="text/javascript"><!-- // create the XMLHttpRequest object, according browser function get_XmlHttp() { // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value) var xmlHttp = null; if(window.XMLHttpRequest) { // for Forefox, IE7+, Opera, Safari, ... xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { // for Internet Explorer 5 or 6 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } return xmlHttp; } // sends data to a php file, via POST, and displays the received answer function ajaxrequest(php_file, tagID) { var request = get_XmlHttp(); // calls the function for the XMLHttpRequest instance // gets data from form fields, using their ID var nume = document.getElementById('nume').value; var mesaj = document.getElementById('mesaj').value; var datepicker = document.getElementById('datepicker').value; var hour = document.getElementById('hour').value; var minute = document.getElementById('minute').value; var dhour = document.getElementById('dhour').value; var dminute = document.getElementById('dminute').value; // create pairs index=value with data that must be sent to server var the_data = 'datepicker='+datepicker+'&hour='+hour+'&minute='+minute+'&dhour='+dhour+'&dminute='+dminute; request.open("POST", php_file, true); // sets the request // adds a header to tell the PHP script to recognize the data as is sent via POST request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(the_data); // sends the request // Check request status // If the response is received completely, will be transferred to the HTML tag with tagID request.onreadystatechange = function() { if (request.readyState == 4) { document.getElementById(tagID).innerHTML = request.responseText; } } } --></script> <style> .left{float:left;} .clear{clear:both;} </style> </head> <body> <br /> <b>Create Appointment</b><br><br> <form action="new.php" method="post" name="form1" onsubmit="ajaxrequest('new.php', 'resp'); return false;"> <label class="left" for="datepicker" id="hour_label" class="small">Hours<br> Date: <input type="text" name="datepicker" id="datepicker"/></label> <br><br><br><br> </form> <br> Trainer Availabity<br> <form action="new.php" method="post" name="form1" onsubmit="ajaxrequest('new.php', 'resp'); return false;"> Your name: <input type="text" name="nume" id="nume" size="20" maxlength="33" /><br /> Your message:<br /> <textarea name="mesaj" id="mesaj" cols="25" rows="4"></textarea><br /> <b>Time</b><br> <label class="left" for="hourid" id="hour_label" class="small">Hours<br> <?php $number = range(00,24); $tempholder = range(00,24); $nr=24; echo '<select class="doba" name="hour" id="hour">'; echo '<option value="" selected="selected">--Select Hour--</option>'; for ($i=0; $i<$nr; $i++) { echo "<option>".$tempholder[$i]."</option>"; } echo '</select>'; ?> </label> <label class="left" for="minute" id="minute_label" class="small">Minute<br> <?php $number = range(1,60); $tempholder = range(1,60); $nr=60; echo '<select name="minute" id="minute">'; echo '<option value="" selected="selected">--Select Minute--</option>'; for ($i=0; $i<$nr; $i++) { echo "<option>".$tempholder[$i]."</option>"; } echo '</select>'; ?> </label> <br><br><br><br> <div class="clear"><b>Duration</b></div> <div class="clear"></div> <label class="left" for="dhour" class="small" id="dhour_label">Hours<br> <?php $number = range(00,05); $tempholder = range(00,05); $nr=5; echo '<select class="doba" name="dhour" id="dhour">'; echo '<option value="" selected="selected">--Select Hour--</option>'; for ($i=0; $i<$nr; $i++) { echo "<option>".$tempholder[$i]."</option>"; } echo '</select>'; ?> </label> <label class="left" for="dminute" class="small" id="dminute_label">Minute<br> <?php $number = range(1,60); $tempholder = range(1,60); $nr=60; echo '<select name="dminute" id="dminute">'; echo '<option value="" selected="selected">--Select Minute--</option>'; for ($i=0; $i<$nr; $i++) { echo "<option>".$tempholder[$i]."</option>"; } echo '</select>'; ?> </label> <input type="submit" value="Search Trainer Availabity" /> </form> <div id="resp"></div> </body> </html> when i remove Your name: <input type="text" name="nume" id="nume" size="20" maxlength="33" /><br /> Your message:<br /> <textarea name="mesaj" id="mesaj" cols="25" rows="4"></textarea><br /> it shows the output php file,not the current file... pls help!!!
  5. I wanted to create a simpe secured login form. after hours of googling i found tat using these will help 1.PDO statements. 2.session_hijackin soultions 3.password protection with salt My questions... 1.what else more should i add?? 2.i want to know if i want to use ajax here, will that make my site less-secured? if so, how do i use send data to check to db via ajax in a secured way?? Help plssss........... huge, loads of thanks in advances...
  6. no this is my first javascript usage.. i just want to have css apply even when i use it 2 reload parts of pages... i just get without-css-formatted data even when i use ID to echo it.. document.getElementById('login_blue_hdr').innerHTML = "done.." like this....
  7. i want to reload parts of my page with the css intact. am using this code to load my css files but doesn't seem to work. if u could where is that am going wrong?? <script type="text/javascript"> $(document).ready(function(){ $.ajax({ url:"css/style.css", success:function(data){ $("<style></style>").appendTo("head").html(data); } }) }) function createObject() { var request_type; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_type = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_type = new XMLHttpRequest(); } return request_type; } var http = createObject() /* -------------------------- */ /* LOGIN */ /* -------------------------- */ /* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */ var nocache = 0; function login() { // Optional: Show a waiting message in the layer with ID ajax_response document.getElementById('login_response').innerHTML = "Loading..." // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. var username= encodeURI(document.getElementById('username').value); var password = encodeURI(document.getElementById('password').value); // Set te random number to add to URL request nocache = Math.random(); // Pass the login variables like URL variable http.open('get', '/login.php?username='+username+'&password='+password+'&nocache = '+nocache); http.onreadystatechange = loginReply; http.send(null); } function loginReply() { if(http.readyState == 4){ var response = http.responseText; if(response == 0){ alert('Login failed! Verify user and password'); } else { alert('Welcome'+response); window.location='home.php'; } } } function forgot() { document.getElementById('login_blue_hdr').innerHTML = "done.." } </script> </head> thanks in advances
  8. sorry for d late reply..i get nothin actually from login.php... no output.. d success case works fine. am havin trouble with not-success part.. i get Welcome ok done for success. and for not-sucess i get just Welcome...
  9. i have a very basic ajax script. It works for if login is successful, but the not when the login is not ok. <script type="text/javascript"> // Wait for the page to load first window.onload = function() { function createObject() { var request_type; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_type = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_type = new XMLHttpRequest(); } return request_type; } var http = createObject(); var a = document.getElementById("login"); //Set code to run when the link is clicked // by assigning a function to "onclick" a.onclick = function() { document.getElementById('login_response').innerHTML = "Loading..." var username = encodeURI(document.getElementById('username').value); var password = encodeURI(document.getElementById('password').value); nocache = Math.random(); http.open('get', 'http://appsmarketing.net/hr/login.php?username='+username+'&password='+password+'&nocache = '+nocache); http.onreadystatechange = loginReply; http.send(null); } function loginReply() { if(http.readyState == 4){ var response = http.responseText; if(response == 0){ document.getElementById('login_response').innerHTML = 'Login failed! Verify user and password'; // else if login is ok show a message: "Welcome + the user name". } else { document.getElementById('login_response').innerHTML = 'Welcome'+response; } } return false; } } </script> </head> <body> <form method="get"> <tbody> <tr> <td >Username: </td> <td ><input type="text" name="username" value="" id="username" class="txt_bg"></td> </tr> <tr> <td>Password: </td> <td ><input type="password" name="password" id="password" value="" class="txt_bg"></td> </tr> <tr> <input id="login" type="submit" value="Login" class="login_btn"></a></div> </tr> </tbody> </table> </form> and the php file is <?php if(isset($_GET['username']) && isset($_GET['password'])){ $uname = $_GET['username']; $psw = $_GET['password']; $aa="SELECT 'mid' FROM `check` WHERE uname='".$uname."' AND password123='".$psw."' AND mid='1'"; $query=mysql_query($aa) or die(mysql_error()); $num_results=mysql_num_rows($query) or die(mysql_error()); if(($query)&&($num_results==1)) {echo "ok done";} else {echo "0";} } ?> i want to make response==0, but the control transfers to the else part of javascript function?? how do i return the false value to get login failed message.. Thanks in advances...
  10. i have a form. if user enter the data, the db table display. but i want the table to get displayed when the user logins for the first time. simple one but i can't get it how... aa.html <html> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var age = document.getElementById('age').value; var wpm = document.getElementById('wpm').value; var sex = document.getElementById('sex').value; var name = document.getElementById('name').value; var queryString = "?age=" + age + "&wpm=" + wpm + "&sex=" + sex + "&name=" + name; $a=ajaxRequest.open("GET", "ss1.php" + queryString, true); ajaxRequest.send(null); } //--> </script> <form name='myForm'> Name:<input type='text' id='name' /> <br /> Age: <input type='text' id='age' /> <br /> WPM: <input type='text' id='wpm' /> <br /> Sex: <select id='sex'> <option value='m'>m</option> <option value='f'>f</option> </select> <input type='button' onclick='ajaxFunction()' value='Insert New row' /> </form> <div id='ajaxDiv'>Your result will display here</div> </body> </html> ss1.php $age = $_GET['age']; $sex = $_GET['sex']; $wpm = $_GET['wpm']; $name= $_GET['name']; // Escape User Input to help prevent SQL Injection $a=isset($_GET['age']) && $_GET['age']; $b=isset($_GET['sex']) && $_GET['sex']; $c=isset($_GET['wpm']) && $_GET['wpm']; $d=isset($_GET['name']) && $_GET['name']; $age = mysql_real_escape_string($age); $sex = mysql_real_escape_string($sex); $wpm = mysql_real_escape_string($wpm); $name = mysql_real_escape_string($name); //build query $query = "INSERT INTO `ajax_example`(`ae_name`, `ae_age`, `ae_sex`, `ae_wpm`) VALUES ('$name','$age','$sex','$wpm')"; $qry = mysql_query($query) or die(mysql_error()); $a="SELECT `ae_name`, `ae_age`, `ae_sex`, `ae_wpm` FROM `ajax_example`"; $qry_result=mysql_query($a) or die(mysql_error()); //Build Result String $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Name</th>"; $display_string .= "<th>Age</th>"; $display_string .= "<th>Sex</th>"; $display_string .= "<th>WPM</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[ae_name]</td>"; $display_string .= "<td>$row[ae_age]</td>"; $display_string .= "<td>$row[ae_sex]</td>"; $display_string .= "<td>$row[ae_wpm]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> if u could tell me show good websites to practice javascript. woulg b gr8.. thank u in advances.
  11. i have 2 tables, items and users. item has => item_id(unique_1), item_describe,item_cost,item_unit_price user => user_name, psws, last_name so whenever user logins inside and adds a item, i want to connect that adding of items with the user. may b looks simple, but i want to do it without adding any extra field in tables.. is that possible.. Or else if i make item_id as primary, then how should i proceed? And if item_id is not unique, if 2 users have same items addition with same id,cost_price, how could that be achieved?? thnks in advance...
  12. thank u.............. it is working ....am makin things so complex ...
  13. Help pls.. i just want to update a field called last_visited date in my table. Each time the user logins. so i tried using this way UPDATE table SET c = c + 1 WHERE a = 1; INSERT INTO table (a, b, c) VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = c + 1; $dd="INSERT INTO file(lname,mid,last_date) VALUES ('$value1','$value2','$value3') ON DUPLICATE KEY UPDATE last_date_a=$value3; mysql_query($dd) or die(mysql_error()); $aa="UPDATE table SET date_a_in=1 WHERE lname='".$_SESSION['lname']."' AND password='".$_SESSION['password']."' AND mid='1'"; mysql_query($aa) or die(mysql_error()); date_a_in is the index i set as unique for last_date field.... Help pls i can't get this.. Thanks a lot in advances......
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.