Jump to content

pritam79

Members
  • Content Count

    92
  • Joined

  • Last visited

Community Reputation

1 Neutral

About pritam79

  • Rank
    Newbie
  1. I have a php site. I also have images stored in folders to be displayed in those pages. But i wanted to know how do i store those images in mysql and display them in my php pages by extracting them from mysql database. please give some scripts to display those image from mysql by the help of php script.
  2. pritam79

    PHP form

    <?phpsession_start();if(isset($_SESSION['userid'])) { if($_SESSION['level']==1) { echo "<div id='navbar'></div>"; header('Refresh: 5; URL=admin.php'); echo "<div id='content'>"; echo "<p><br>You are already logged-in as admin, and will be re-directed to your home page.</br>"; echo "If your browser doesnot redirect you automatically, <a href='admin.php'>click here</a>.</p>"; include "footer.php"; exit; } if($_SESSION['level']==2) { echo "<div id='navbar'></div>"; header('Refresh: 5; URL=mypage.php'); echo "<d
  3. pritam79

    insert error

    its all working now. just had some problem with the database table structure. Now when I register, I am trying to execute multiple insert queries at the same time as given below. $sql = "INSERT INTO company_com (id_com, idusr_com) VALUES ('', '".$_SESSION['id_usr']."')"; mysql_query($sql, $result) or die(mysql_error($result)); $_SESSION['id_com'] = mysql_insert_id($result); $sql = "INSERT INTO domain_dom (id_dom) VALUES ('')"; mysql_query($sql, $result) or die(mysql_error($result)); $sql = "INSERT INTO location_loc (id_loc) VALUES ('')"; mysql_query($sql, $result) or die(mysq
  4. pritam79

    insert error

    I tried the following for user registration.$sql = "INSERT INTO user_usr (id_usr, username_usr, password_usr, level_usr, email_usr) VALUES ('', '$username', '$password', '1', '$email')"; mysql_query($sql, $result) or die(mysql_error($result)); echo $sql; exit; The user was registered as before with the values getting inserted into MySql as earlier. But on echoing $sql I get this output in the browser window-INSERT INTO user_usr (id_usr, username_usr, password_usr, level_usr, email_usr) VALUES ('', 'User7', 'User7', '1', 'user7@gmail.com')
  5. pritam79

    insert error

    I removed the apostrophes from ‘1’ and ‘2’ (int type) of the two insert queries, but even now only zeros are getting inserted in MySql. But when I echo $_SESSION['level_usr'] on the page where a user is redirected after registration, I get the proper output as 1 or 2 depending on who registered (user or company). Its showing 0 in the table evertime I register be it a user or a company.Also, the length of the email field is varchar(25), but still the problem persists.
  6. pritam79

    insert error

    This is register_company.php<?phpsession_start();if(isset($_SESSION['id_usr'])){ if($_SESSION['level_usr']=1) { header('Location:user/index.php'); exit; } if($_SESSION['level_usr']=2) { header('Location:company/index.php'); exit; }}if($_SERVER['REQUEST_METHOD'] == 'POST'){ if(strlen($_POST['txtusername']) !='' && strlen($_POST['txtpassword']) !='' && strlen($_POST['txtemail']) !='') { require("db-connect.php"); $result = db_connect(); if($result) { $username = mysql_real_escape_string($_POST['txtusername'], $result); $password = mysql_real_escape_s
  7. pritam79

    insert error

    I have two pages ‘register_user.php’ which allows job-applicants to register, and ‘register_company.php’ which allows the companies to register. I am using wamp. A job-applicant or Company gets registered properly, but the only errors I get are- level_usr gets inserted in the tables as 0 in both cases whereas it should have inserted a 1 for an applicant, and 2 for a company. Also, the email field value of the table is inserted as - it begins with some weird character and then the address followed by a dot, but the com after the dot is absent.
  8. pritam79

    insert error

    I have two pages ‘register_user.php’ which allows job-applicants to register, and ‘register_company.php’ which allows the companies to register. I am using wamp. A job-applicant or Company gets registered properly, but the only errors I get are- level_usr gets inserted in the tables as 0 in both cases whereas it should have inserted a 1 for an applicant, and 2 for a company. Also, the email field value of the table is inserted as illustrated in the image. (attachment)
  9. pritam79

    Php Mysql Error

    I created this mysql table using WAMP server's PHPMyAdmin interface- id_com (pk), idusr_com(fk),name_com, address_comAlso there is some PHP code as shown below- require("db-connect.php"); $db = db_connect(); $name_com = mysql_real_escape_string($_POST['txtname_com'], $db); $address_com = mysql_real_escape_string($_POST['txtaddress_com'], $db); if($db) { if(isset($_POST['Add'])) { // insert company name and location in company_com $sql = "INSERT INTO company_com(name_com, address_com) VALUES ('$name_com', '$address_com') WHERE idusr_com = ".$_SESSION[id_
  10. The above script uses sessions to track a user throughout the site. But as I close the browser, the next time the user has to log in again. I want the 'remember me' checkbox to work. That is if a user logs in by checking 'remember me' and then closes the browser, the next time the same user requests the page he need not enter the username and password and is automatically redirected to his home page.
  11. Hi all,I am using the following login script that uses just sessions. Even in the other pages, which a user views after logging in, use sessions. I want to use sessions and cookies together in the login script as well as in all the later pages, which would lessen the server load. I want to include cookies as well, so that the two (cookies+sessions) function together. How can I do so? Please illustrate. Thanks.. <?phpsession_start();if(isset($_SESSION['id_usr'])){ if($_SESSION['level_usr']==1) { include "header.php"; echo "<div id='navbar'></div&
  12. pritam79

    Foreign Keys

    Hi all,I have the following two tables in MySQL. When I insert a record in the ‘user-usr’ table, I want the foreign key ‘idusr_com’ to get inseted in the company_com table accordingly. What is the appropriate SQL statement to do so? Do I need two queries? What happens when I need to insert foreign key values in many tables at a time?1. company_com - to store the company main information. id_com - the primary key for the company table. No two companies can have the same ID. idusr_com - a foreign key to the company's entry in the users table below. Login and access restrictions are s
  13. Hi all, My question is related to both PHP and JavaScript, and as such didn’t know the forum where to post my query.Firstly, I would like to know if JavaScript can be totally done away with from a PHP page. That is, can a site,developed entirely in PHP (minus JavaScript), perform all functions that could otherwise be performed by using JavaScript embedded into the PHP pages? Secondly, what choice does a developer have in case he does not want to include JavaScript at all in a site developed entirely in PHP? Would the exclusion of JavaScript make the site less functional? Is there anything t
  14. pritam79

    PHP login

    I want the scripts to do the following.1. Accept a valid username and password.2. Authenticate the user against the database and serve the ‘authormaster.php’ page if validated.3. If the REMEMBER ME option is selected on the login page, then the next time the user logs-in the server should directly serve the user with ‘authormaster.php’.4. The ‘authormaster.php’ page should allow users to do the following- a) Sign Out – brings the user back to login.php and populates the ‘username’ field with the last username used to login. Change User – allows the user to login as a different user by bring
  15. pritam79

    PHP login

    I got the code in a book. I doubt the code would work but the functioning is such that the user will first login through 'login.php', which will use the script 'setme.php' to verify if the username and password are in the database, and if so will redirect the user to 'authormaster.php'. But the script is not working.
×
×
  • Create New...