Jump to content

mintoo2cool

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mintoo2cool's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i have a file connection.php, that contains functions to connect and disconnect from database. the functions are as follows: <?php //connection.php file function connect() { $con = mysql_connect("localhost","abcd","123456"); if(!$con) die ('Error! could not connect to data to add data'); return $con; } function disconnect($con) { mysql_close($con); } ?> I my intent is to use these functions whenever i would need to connect to database. When i include this file, using include() or require(). I get the warning message, and the page does not redirect to the next page. For example I have created a login page that accepts username and password. The data from this form is "processed" in a login_proc.php file, that redirects the browser to home.php or loginerror.php. But instead of working as I desire, PHP stops with a warning stating the following. Warning: Cannot modify header information - headers already sent by (output started at /home1/mintoo/public_html/bew_system/login_proc.php:5) in /home1/mintoo/public_html/bew_system/login_proc.php on line 20 How do I avoid this warning? This is the code in login_proc.php for your reference <?php //login_proc.php include 'resources/connection.php'; $con= connect(); ob_flush(); $uname = mysql_real_escape_string(strip_tags(substr($_POST['uname'],0,30))); $pass = mysql_real_escape_string(strip_tags(substr($_POST['pwd'],0,30))); $query = "select userid from mintoo_db1.tbl_users where userid='$uname' and password='$pass'"; $result = mysql_query($query); $nofrows = mysql_num_rows($result); disconnect($con); if($nofrows == 0) echo '<h2>Incorrect Username or Password</h2><br/><a href="login.php">Try again</a>'; else if($nofrows == 1) header("location: home.php"); else echo '<h2><u> Error-001:</u>An unexpected error has occured. Please go back and try again after some time or contact system administrator</h2>'; ?> EDIT: Solved it Made the following changes to login_proc.php <?php ob_start(); include 'resources/connection.php'; $con= connect(); $uname = mysql_real_escape_string(strip_tags(substr($_POST['uname'],0,30))); $pass = mysql_real_escape_string(strip_tags(substr($_POST['pwd'],0,30))); $query = "select userid from mintoo_db1.tbl_users where userid='$uname' and password='$pass'"; $result = mysql_query($query); $nofrows = mysql_num_rows($result); disconnect($con); if($nofrows == 0) echo '<h2>Incorrect Username or Password</h2><br/><a href="login.php">Try again</a>'; else if($nofrows == 1) { header("location: home.php"); } else echo '<h2><u> Error-001:</u>An unexpected error has occured. Please go back and try again after some time or contact system administrator</h2>'; ob_flush(); ?>
  2. How to configure the server to restrict a user from accessing the directory structure, by changing the URL? for example: if the server redirects the user to the following URL upon successful login. http://mysite/dir1/dir2/dir3/phpfile.php currently, if i try change the URL to http://mysite/dir1/ even though there is no index webpage for dir1/, the directory structure gets exposed. how do i go about restricting the user from accessing the directory structure and throw an error message at him like "you are not authorised to view this", whenever a "smarty-pants" user tries to edit the URL manually. The user should only be able to see the webpages which the server redirects him to. nothing else. How to configure the PHP server such that, if the URL is modified manually, server should redirect to an error page instead of exposing the directory structure.
  3. thats what i have been wanting to learn and understand! thank you indeed!
  4. Yeah that fixed a part of the issue, but not the entire issue. Basically, I want imono2 (present in vessal_of_owner.php) to be shown in general_particulars2.php 's source code, after its rendered by php engine. Presently imono2 is being rendered in the innerHTML of imono in general_particular2.php. Therefore I'm not able to see it when i try to view general_particular2.php's source code after it has rendered in Internet Explorer or Opera. Is there anyway to access imono2 in general_particular2.php so that i may use it for further manipulation( like use the value of imono2 in another query to fetch other data form the database )? Because I am not able to do that right now. I want to able to use the value in imono2 to query the database and fetch the name of the vessal and place it in another textbox which is present in general_particular2.php. (EDIT: bolded the names of files and tags, to avoid confusion. )
  5. beside the "Vessal IMO no", there is a <div> tag. thats actually supposed to be imono. i dont know how it became imono2. thats the one i m altering.
  6. I'm sorry about the delay. I was asleep. Probably a timezone thing. here is the requested data [attachment deleted by admin]
  7. alright, PFA 1. general_particulars2.php (this is the mainpage) 2. gp_ajax/vessal_of_owner.php 3. gp_ajax/equip_bearing_no.php 4.SQL DDL which you can execute in your database, pls add some dummy data yourself, for testing. 2.,3. are called by the javascript functions in general_particulars2.php Additionally I have attached the DDL of the relevant tables, FYR. thanks for trying to help out titan21. really appreciate the generosity :-) [attachment deleted by admin]
  8. oops... forgot to mention where i m getting stuck. well, its step 3 really, when i m getting stuck. in the original html form, i m able to see the dropdown, being generated in step2 (thanks to the http response generated by the vessal_of_owner.php page). but when i view the source code of this html file, i dont see the tag for step2! And if i don't see the select tag corresponding to step 2, i wont be able to call it onchange event and use it, to fetch data for step 3!
  9. okay ,basically this is what i want to achieve. 1. when user opens the php webpage. he gets to choose from a list of vessal owners. 2. when the user selects an owner, he should be able to choose the vessal based on a number (the imo number , tagged as imono), from a dropdown containing the list of vessals owned by the owner selected in step 1 only. 3. after the user selects the imo number, the corresponding name of the vessal, based on the imo number(retrived from database), should be shown in the text box below it. here is the php code of vessal_of_owner.php <?php $con = mysql_connect("localhost","bew","123456"); if(!$con) { die ('Error! could not connect to data to add data'); } $ownerid = $_GET['ownerid']; $result = mysql_query("select vessalid,vessalIMONo, vessalname from db1.tbl_vessal where ownerid='$ownerid'"); echo '<select name="imono2" id="imono2">'; while($row = mysql_fetch_array($result)) { echo '<option value="'.$row['vessalid'].'">'.$row['vessalIMONo'].'</option>'; } echo '</select></td></tr>'; mysql_close($con); ?>
  10. i m echoing the entire select tag in the php file, which is called by the javascript function. this echo is captured XMLHttpRequest object and this objects responseText variable is assigned to the innerhtml variable of the div tag. thats how i m managing to generate the dropdown. function showVessals(str) { if (str=="") { document.getElementById("imono").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("imono").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","gp_ajax/vessal_of_owner.php?ownerid="+str,true); xmlhttp.send(); }
  11. well i got it working using AJAX. however, am stuck having a new problem. here is the scenerio. htmlpage1: dropdown1 onchange invokes a javascript function that inturn executes php script at server and the server sends another drop down(which is again populated from the database, call it dropdown2) which is promptly placed at a div tag whose innerhtml javascript is modifying. now what i want is that when user selects from dropdown2, the textbox below it should have the corresponding value. here is my problem. the dropdown2 does not show up in the original html page, so i m not able to access dropdown2 from original htmlpage1 and call another javascript function to fetch data for the textbox. so how do i go about doing this? is there anyway to make innerhtml code appear as original html?
  12. i have a pretty lengthy form that i am having to deal with. at the very top there is a dropdown menu, that will get populated by values from a database table. what my requirement is that, when a user selects the value from the drop down, the corresponding textfields get populated with the correct data automatically. heres an hypothetical example, explaining my requirement: say i have 5 fields in the form. the first one, the username, is a dropdown. the other 3 are phone number, gender, address and they are all text boxes. the last text box would be the users password, which he what i would want to do is, as soon as the user selects a username from the dropdown, the text boxes should automatically populate with that user's phone number, gender and address. the user would then verify this information, then he would write a password in the password field and click on the submit button, which would cause all this data to be stored in a database table. i dont know how to do this ... can anyone give me a push in the right direction on how to getting this accomplished. i m sure this is pretty much possible. i have seen php website, where once the user enters his zip code, the city name automatically is filled up. but i dont know how to do it. I am not that keen on using AJAX here, i ll content even if the entire page would be submitted upon selection.
×
×
  • 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.