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.
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 49
  1. #16
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    actual project shared

    Quote Originally Posted by Dormilich View Post
    how is that code related to your original question?


    PS. storing the users’ passwords in plain text is a HUGE security risk. normally you would just save the password’s hash and if a user has forgotten his password, you’d just create a new one for him that he can reset later.
    my dear,
    how to provide users the reset and get the new password.?
    have you checked the and test the files by creating account?
    i just want to add tu recehe password reset/forgot option to the exiting project.
    if you receive the project files then i will send it to you as the link was pasted in the yesterday?
    thanks in advance
    best regards
    adnan

  2. #17
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    please now check the code as well as database that i already provided to you.
    what is/are the problems now and what suggestions.
    also i added the user database file in the hosting directory.
    the is need of that file or not .
    forgot.php
    <?php session_start();
    include "connect.php"; //connects to the database
    if (isset($_POST['email'])){
    $email = $_POST['email'];
    $query="select * from user where email='$email'";
    $result = mysql_query($query);
    $count=mysql_num_rows($result);
    // If the count is equal to one, we will send message other wise display an error message.
    if($count==1)
    {
    $rows=mysql_fetch_array($result);
    $pass = $rows['password'];//FETCHING PASS
    //echo "your pass is ::".($pass)."";
    $to = $rows['email'];
    //echo "your email is ::".$email;
    //Details for sending E-mail
    $from = "Map My Way";
    $url = "http://myproject.6te.net";
    $body = "Map My Way password recovery Script
    -----------------------------------------------
    Url : $url;
    email Details is : $to;
    Here is your password : $pass;
    Sincerely,
    Coding Cyber";
    $from = "adnansh89ahi@gmail.com";
    $subject = "Map My Way Password recovered";
    $headers1 = "From: $from\n";
    $headers1 .= "Content-type: text/html;charset=iso-8859-1\r\n";
    $headers1 .= "X-Priority: 1\r\n";
    $headers1 .= "X-MSMail-Priority: High\r\n";
    $headers1 .= "X-Mailer: Just My Server\r\n";
    $sentmail = mail ( $to, $subject, $body, $headers1 );
    } else
    {
    echo "<span style='color: #ff0000;'> Not found your email in our database</span>";
    }
    }
    //If the message is sent successfully, display sucess message otherwise display an error message.
    if($sentmail==1)
    {
    echo "<span style='color: #ff0000;'> Your Password Has Been Sent To Your Email Address.</span>";
    }
    else
    {
    if($_POST['email']!="")
    echo "<span style='color: #ff0000;'> Cannot send password to your e-mail address.Problem with sending mail...</span>";
    }

    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>CodingCyber - Simple Script to send Forgotten password</title>
    </head>
    <body>


    <div class="register-form">
    <?php
    if(isset($msg) & !empty($msg)){
    echo $msg;
    }
    ?>
    <h1>Forgot Password</h1>
    <form action="" method="POST">
    <p><label>User Name : </label>
    <input id="email" type="text" name="email" placeholder="email" /></p>

    <input class="btn register" type="submit" name="submit" value="Submit" />
    </form>
    </div>

    </body>
    </html>




    connect.php



    <?php
    $connection = mysql_connect('localhost', '819903', 'adnanno1','819903');
    if (!$connection){
    die("Database Connection Failed" . mysql_error());
    }
    $select_db = mysql_select_db('819903');
    if (!$select_db){
    die("Database Selection Failed" . mysql_error());
    }








    user.sql




    -- phpMyAdmin SQL Dump
    -- version 4.0.4
    -- phpMyAdmin
    --
    -- Host: localhost
    -- Generation Time: Dec 15, 2013 at 05:45 PM
    -- Server version: 5.6.12-log
    -- PHP Version: 5.4.16

    SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    SET time_zone = "+00:00";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;

    --
    -- Database: `test`
    --

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

    --
    -- Table structure for table `user`
    --

    CREATE TABLE IF NOT EXISTS `user` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `username` varchar(255) NOT NULL,
    `email` varchar(255) NOT NULL,
    `password` varchar(255) NOT NULL,
    `active` tinyint(1) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `username` (`username`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

    --
    -- Dumping data for table `user`
    --

    INSERT INTO `user` (`id`, `email`, `email`, `password`, `active`) VALUES
    (2, '819903', '', 'password', 0),
    (3, 'info', '', '819903', 0),
    (4, 'test1', 'adnanshahid89@gmail.com', '819903', 0);

    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;



    thanks
    good morning

  3. #18
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    how to provide users the reset and get the new password.?
    How I would do it:
    if they click the "forgot password" link it would run a script that
    - ask for some kind of verification (otherwise anyone could reset your password anytime)
    - creates a new password
    - calculates its hash and save that to the DB
    - sends the new password to the user’s email address
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  4. #19
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    How I would do it:
    if they click the "forgot password" link it would run a script that
    - ask for some kind of verification (otherwise anyone could reset your password anytime)
    - creates a new password
    - calculates its hash and save that to the DB
    - sends the new password to the user’s email address
    please check the code it works for email but not able to reset the password after change password.

    this is the forgot.php

    <?php
    error_reporting(0);
    if($_POST['submit']=='Send')
    {
    //keep it inside
    $email=$_POST['email'];
    $code = $_GET['activation_code'];
    $con=mysqli_connect("localhost","819903","adnanno1","819903");
    // Check connection
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $query = mysqli_query($con,"select * from members where email='$email'")
    or die(mysqli_error($con));

    if (mysqli_num_rows ($query)==1)
    {
    $code=rand(100,999);
    $message="You activation link is: http://myproject.6te.net/resetpass.php?email=$email&code=$code";
    mail($email, "myproject.6te.net", $message);
    echo 'Email sent';
    $query2 = mysqli_query($con,"update members set activation_code='$code' where email='$email' ")
    or die(mysqli_error($con));
    }
    else
    {
    echo 'No user exist with this email id';

    }}

    ?>
    <form action="forgot.php" method="post">
    Enter you email ID: <input type="text" name="email">
    <input type="submit" name="submit" value="Send">
    </form>




    and this is the resetpass.php


    <?php

    if(isset($_POST['pass'])){
    $pass = $_POST['pass'];
    $acode=$_POST['code'];

    $con=mysqli_connect("localhost","819903","adnanno1","819903");
    // Check connection
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $query = mysqli_query($con,"select * from members where activation_code='$acode'")
    or die(mysqli_error($con));

    if (mysqli_num_rows ($query)==1)
    {
    $query3 = mysqli_query($con,"update members set Password='$pass' where activation_code='$acode'")
    or die(mysqli_error($con));

    echo 'Password Changed';
    }
    else
    {
    echo 'Wrong CODE';
    }
    }
    ?>

    <form action="resetpass.php" method="POST">
    <p>New Password:</p><input type="password" name="pass" />
    <input type="submit" name="submit" value="Signup!" />
    <input type="hidden" name="code" value="<?php echo $_GET['code'];?>" />
    </form>

    please check that for what reason the password is not changing.?
    thanks in advance.
    best regards
    adnan shahid

  5. #20
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    first of all, post your code wrapped in code tags, otherwise it’s a pain to read.

    forgot.php
    - there is no activation code passed along
    - you’re totally susceptible to SQL Injection
    - there is no guarantee that your email is sent at all (mail just passes it to the OS)
    - error_reporting(0) means you get no error message (which is counter-productive in debugging)

    resetpass.php
    - you’re totally susceptible to SQL Injection

    generally, statements like "it’s not working" are futile because it doesn’t help debugging.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  6. #21
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    my dear,
    now i made the following changes in the code and following changes are observed as problems.

    <?php
    ob_start();
    session_start();
    if(!isset($_SESSION['Username'])){
    header("Location: login.php");
    }


    ?>
    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header("Location: login.php");
    echo "<html>";
    echo "<head><title>SUCCESSFULLY LOGGED IN TO MAP MY WAY</title></head>";
    echo "<body>";
    echo "<font color='maroon'><center><h1>BCA Board</h1></center><table border=1 bgcolor='lightgreen' height=600 width=900>";
    echo "<th>Comment</th><th>Author</th><th>DisplayPic</th>";

    $con=odbc_connect('localhost','819903',' adnanno1');
    if(!$con)
    echo "not connected";
    $qry="select * from members";
    $rs=odbc_exec($con,$qry);
    $uname=$_SESSION["unm"];
    while(odbc_fetch_row($rs))
    {
    echo "<tr>";
    $dis=odbc_result($rs,3);
    if($dis=="")
    $dis="displaypic/anonymous.jpg";
    echo "<td width='500'>".odbc_result($rs,2)."</td><td>".odbc_result($rs,1)."</td><td><img src='$dis' width=100 height=100></td>";
    if($uname==odbc_result($rs,1))
    echo "<td><form action='deletepost.php' method='post'><input type='hidden' name='delpost' value='".odbc_result($rs,2)."'><input type='submit' value='Delete'></form></td>";
    }
    echo "</table>";
    echo "<center><form name='myform' action='addpost.php' method='post'><textarea rows='5' cols='40' name='msg'></textarea><br><input type='submit' value='Discuss'></form></center>";
    echo "<br>";
    echo "<center>";

    echo "</center>";
    echo "</body>";
    ?>
    <!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>Member Area </title>
    <style type="text/css">
    .success {
    border: 1px solid;
    margin: 0 auto;
    padding:10px 5px 10px 60px;
    background-repeat: no-repeat;
    background-position: 10px center;
    font-weight:bold;
    width:450px;
    color: #4F8A10;
    background-color: #DFF2BF;
    background-image:url('images/success.png');

    }



    </style>
    </head>

    <body>
    <div class="success">Welcome , <?php echo $_SESSION['Username'] ; ?></div>
    </body>
    </html>


    this is addpost.php

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header('location:index.html');
    $con=odbc_connect('localhost','819903','adnanno1');
    $msg=$_POST["msg"];
    if(!$con)
    echo "not connected";

    $email=$_SESSION["unm"];
    $qry="select * from members where email='$email'";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "record addition failed";
    $displ=odbc_result($rs,7);
    $qry="insert into forum values('$email','$msg','$displ')";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "record addition failed";

    ?>



    and this is deletepost.php

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header('location:index.html');
    $msg=$_POST["delpost"];
    $con=odbc_connect('localhost','819903','adnanno1');
    $qry="delete from forum where comment='$msg'";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "no record deleted";

    ?>

  7. #22
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    now i made the following changes in the code and following changes are observed as problems.
    what problems do you observe exactly.

    please post your code wrapped in [ CODE ] [ / CODE ]
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  8. #23
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    what problems do you observe exactly.

    please post your code wrapped in [ CODE ] [ / CODE ]
    my dear,
    I want to add the home page to my existing system .
    The first file is login.php that works fine when the following code is not added into that and logg inn successfully.
    but when the following code is added that uses other two files the lgg in stops working and nothing happen.
    you can check at here.
    Registration Form
    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header("Location: login.php");
    echo "<html>";
    echo "<head><title>SUCCESSFULLY LOGGED IN TO MAP MY WAY</title></head>";
    echo "<body>";
    echo "<font color='maroon'><center><h1>BCA Board</h1></center><table border=1 bgcolor='lightgreen' height=600 width=900>";
    echo "<th>Comment</th><th>Author</th><th>DisplayPic</th>";

    $con=odbc_connect('localhost','819903',' adnanno1');
    if(!$con)
    echo "not connected";
    $qry="select * from members";
    $rs=odbc_exec($con,$qry);
    $uname=$_SESSION["unm"];
    while(odbc_fetch_row($rs))
    {
    echo "<tr>";
    $dis=odbc_result($rs,3);
    if($dis=="")
    $dis="displaypic/anonymous.jpg";
    echo "<td width='500'>".odbc_result($rs,2)."</td><td>".odbc_result($rs,1)."</td><td><img src='$dis' width=100 height=100></td>";
    if($uname==odbc_result($rs,1))
    echo "<td><form action='deletepost.php' method='post'><input type='hidden' name='delpost' value='".odbc_result($rs,2)."'><input type='submit' value='Delete'></form></td>";
    }
    echo "</table>";
    echo "<center><form name='myform' action='addpost.php' method='post'><textarea rows='5' cols='40' name='msg'></textarea><br><input type='submit' value='Discuss'></form></center>";
    echo "<br>";
    echo "<center>";

    echo "</center>";
    echo "</body>";
    ?>
    <!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>Member Area </title>
    <style type="text/css">
    .success {
    border: 1px solid;
    margin: 0 auto;
    padding:10px 5px 10px 60px;
    background-repeat: no-repeat;
    background-position: 10px center;
    font-weight:bold;
    width:450px;
    color: #4F8A10;
    background-color: #DFF2BF;
    background-image:url('images/success.png');

    }

    this is addpost.php

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header('location:index.html');
    $con=odbc_connect('localhost','819903','adnanno1');
    $msg=$_POST["msg"];
    if(!$con)
    echo "not connected";

    $email=$_SESSION["unm"];
    $qry="select * from members where email='$email'";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "record addition failed";
    $displ=odbc_result($rs,7);
    $qry="insert into forum values('$email','$msg','$displ')";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "record addition failed";

    ?>
    and this is deletepost.php

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header('location:index.html');
    $msg=$_POST["delpost"];
    $con=odbc_connect('localhost','819903','adnanno1');
    $qry="delete from forum where comment='$msg'";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "no record deleted";

    ?>

  9. #24
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    actually this is the added code and latter files that uses the code.
    sorry the first full code is added by mistake.

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header("Location: login.php");
    echo "<html>";
    echo "<head><title>SUCCESSFULLY LOGGED IN TO MAP MY WAY</title></head>";
    echo "<body>";
    echo "<font color='maroon'><center><h1>BCA Board</h1></center><table border=1 bgcolor='lightgreen' height=600 width=900>";
    echo "<th>Comment</th><th>Author</th><th>DisplayPic</th>";

    $con=odbc_connect('localhost','819903',' adnanno1');
    if(!$con)
    echo "not connected";
    $qry="select * from members";
    $rs=odbc_exec($con,$qry);
    $uname=$_SESSION["unm"];
    while(odbc_fetch_row($rs))
    {
    echo "<tr>";
    $dis=odbc_result($rs,3);
    if($dis=="")
    $dis="displaypic/anonymous.jpg";
    echo "<td width='500'>".odbc_result($rs,2)."</td><td>".odbc_result($rs,1)."</td><td><img src='$dis' width=100 height=100></td>";
    if($uname==odbc_result($rs,1))
    echo "<td><form action='deletepost.php' method='post'><input type='hidden' name='delpost' value='".odbc_result($rs,2)."'><input type='submit' value='Delete'></form></td>";
    }
    echo "</table>";
    echo "<center><form name='myform' action='addpost.php' method='post'><textarea rows='5' cols='40' name='msg'></textarea><br><input type='submit' value='Discuss'></form></center>";
    echo "<br>";
    echo "<center>";

    echo "</center>";
    echo "</body>";
    ?>

  10. #25
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    please wrap your code in CODE tags, not QUOTE tags.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  11. #26
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    my dear,
    I want to add the home page to my existing system .
    The first file is login.php that works fine when the following code is not added into that and logg inn successfully.
    but when the following code is added that uses other two files the lgg in stops working and nothing happen.
    you can check at here.
    Registration Form

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header("Location: login.php");
    echo "<html>";
    echo "<head><title>SUCCESSFULLY LOGGED IN TO MAP MY WAY</title></head>";
    echo "<body>";
    echo "<font color='maroon'><center><h1>BCA Board</h1></center><table border=1 bgcolor='lightgreen' height=600 width=900>";
    echo "<th>Comment</th><th>Author</th><th>DisplayPic</th>";

    $con=odbc_connect('localhost','819903',' adnanno1');
    if(!$con)
    echo "not connected";
    $qry="select * from members";
    $rs=odbc_exec($con,$qry);
    $uname=$_SESSION["unm"];
    while(odbc_fetch_row($rs))
    {
    echo "<tr>";
    $dis=odbc_result($rs,3);
    if($dis=="")
    $dis="displaypic/anonymous.jpg";
    echo "<td width='500'>".odbc_result($rs,2)."</td><td>".odbc_result($rs,1)."</td><td><img src='$dis' width=100 height=100></td>";
    if($uname==odbc_result($rs,1))
    echo "<td><form action='deletepost.php' method='post'><input type='hidden' name='delpost' value='".odbc_result($rs,2)."'><input type='submit' value='Delete'></form></td>";
    }
    echo "</table>";
    echo "<center><form name='myform' action='addpost.php' method='post'><textarea rows='5' cols='40' name='msg'></textarea><br><input type='submit' value='Discuss'></form></center>";
    echo "<br>";
    echo "<center>";

    echo "</center>";
    echo "</body>";
    ?>
    <!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>Member Area </title>
    <style type="text/css">
    .success {
    border: 1px solid;
    margin: 0 auto;
    padding:10px 5px 10px 60px;
    background-repeat: no-repeat;
    background-position: 10px center;
    font-weight:bold;
    width:450px;
    color: #4F8A10;
    background-color: #DFF2BF;
    background-image:url('images/success.png');

    }
    this is addpost.php


    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header('location:index.html');
    $con=odbc_connect('localhost','819903','adnanno1');
    $msg=$_POST["msg"];
    if(!$con)
    echo "not connected";

    $email=$_SESSION["unm"];
    $qry="select * from members where email='$email'";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "record addition failed";
    $displ=odbc_result($rs,7);
    $qry="insert into forum values('$email','$msg','$displ')";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "record addition failed";

    ?>
    and this is deletepost.php


    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header('location:index.html');
    $msg=$_POST["delpost"];
    $con=odbc_connect('localhost','819903','adnanno1');
    $qry="delete from forum where comment='$msg'";
    $rs=odbc_exec($con,$qry);
    if(!$rs)
    echo "no record deleted";

    ?>
    thanks
    best regards
    adnan shahid

  12. #27
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    actually this is the added code and latter files that uses the code.
    sorry the first full code is added by mistake.

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header("Location: login.php");
    echo "<html>";
    echo "<head><title>SUCCESSFULLY LOGGED IN TO MAP MY WAY</title></head>";
    echo "<body>";
    echo "<font color='maroon'><center><h1>BCA Board</h1></center><table border=1 bgcolor='lightgreen' height=600 width=900>";
    echo "<th>Comment</th><th>Author</th><th>DisplayPic</th>";

    $con=odbc_connect('localhost','819903',' adnanno1');
    if(!$con)
    echo "not connected";
    $qry="select * from members";
    $rs=odbc_exec($con,$qry);
    $uname=$_SESSION["unm"];
    while(odbc_fetch_row($rs))
    {
    echo "<tr>";
    $dis=odbc_result($rs,3);
    if($dis=="")
    $dis="displaypic/anonymous.jpg";
    echo "<td width='500'>".odbc_result($rs,2)."</td><td>".odbc_result($rs,1)."</td><td><img src='$dis' width=100 height=100></td>";
    if($uname==odbc_result($rs,1))
    echo "<td><form action='deletepost.php' method='post'><input type='hidden' name='delpost' value='".odbc_result($rs,2)."'><input type='submit' value='Delete'></form></td>";
    }
    echo "</table>";
    echo "<center><form name='myform' action='addpost.php' method='post'><textarea rows='5' cols='40' name='msg'></textarea><br><input type='submit' value='Discuss'></form></center>";
    echo "<br>";
    echo "<center>";

    echo "</center>";
    echo "</body>";
    ?>

  13. #28
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    actually this is the added code and latter files that uses the code.
    sorry the first full code is added by mistake.

    <?php
    session_start();
    if(!($_SESSION['id']==session_id()))
    header('location:index.html');
    if(!(isset($_SESSION['id'])))
    header("Location: login.php");
    echo "<html>";
    echo "<head><title>SUCCESSFULLY LOGGED IN TO MAP MY WAY</title></head>";
    echo "<body>";
    echo "<font color='maroon'><center><h1>BCA Board</h1></center><table border=1 bgcolor='lightgreen' height=600 width=900>";
    echo "<th>Comment</th><th>Author</th><th>DisplayPic</th>";

    $con=odbc_connect('localhost','819903',' adnanno1');
    if(!$con)
    echo "not connected";
    $qry="select * from members";
    $rs=odbc_exec($con,$qry);
    $uname=$_SESSION["unm"];
    while(odbc_fetch_row($rs))
    {
    echo "<tr>";
    $dis=odbc_result($rs,3);
    if($dis=="")
    $dis="displaypic/anonymous.jpg";
    echo "<td width='500'>".odbc_result($rs,2)."</td><td>".odbc_result($rs,1)."</td><td><img src='$dis' width=100 height=100></td>";
    if($uname==odbc_result($rs,1))
    echo "<td><form action='deletepost.php' method='post'><input type='hidden' name='delpost' value='".odbc_result($rs,2)."'><input type='submit' value='Delete'></form></td>";
    }
    echo "</table>";
    echo "<center><form name='myform' action='addpost.php' method='post'><textarea rows='5' cols='40' name='msg'></textarea><br><input type='submit' value='Discuss'></form></center>";
    echo "<br>";
    echo "<center>";

    echo "</center>";
    echo "</body>";
    ?>

  14. #29
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    please wrap your code in CODE tags, not QUOTE tags.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  15. #30
    New Coder
    Join Date
    Jun 2014
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Adding and retrieving from the database

    PHP Code:
    [PHP]<?php
    ob_start
    ();
    require(
    "config.php");
    ob_end_clean();

    $req=$_REQUEST['name'];
    $req2=$_REQUEST['fueltype'];
    $req1=$_REQUEST['color'];
    $req3=$_REQUEST['capacity'];

    mysql_connect("localhost",$username,$password);
    mysql_select_db($database) or die( "Unable to select database");

    if (
    $req!="all" && $req2!="all")  $query="SELECT * FROM vehicles WHERE name='$req' AND fueltype='$req2'";
    else if(
    $req=="all" && $req2!="all" $query="SELECT * FROM vehicles WHERE fueltype='$req2'";
    else if(
    $req!="all" && $req2=="all" $query="SELECT * FROM vehicles WHERE name='$req'";
    else if(
    $req=="all" || $req2=="all" $query="SELECT * FROM vehicles";

    $result=mysql_query($query);
    $num=mysql_numrows($result);

    mysql_query($result);
    mysql_close();

    $i=0;

    for (
    $i$i $num$i++){
        
    $f11=mysql_result($result,$i,"name");
        
    $f12=mysql_result($result,$i,"color");
        
    $f13=mysql_result($result,$i,"capacity");
        
    $f14=mysql_result($result,$i,"fueltype");
        
    echo 
    "$f11";
    echo 
    "$f12";
    echo 
    "$f13";
    echo 
    "$f14";

    }
    ?>
    [/PHP]acltually this is the file that i have made changes to
    on line 33 echo f11,f12 etc shoes errors in both the cases
    PHP Code:
    <?php
    ob_start
    ();
    require(
    "config.php");
    ob_end_clean();

    $req=$_REQUEST['name'];
    $req2=$_REQUEST['fueltype'];
    $req1=$_REQUEST['color'];
    $req3=$_REQUEST['capacity'];

    mysql_connect("localhost",$username,$password);
    mysql_select_db($database) or die( "Unable to select database");

    if (
    $req!="all" && $req2!="all")  $query="SELECT * FROM vehicles WHERE name='$req' AND fueltype='$req2'";
    else if(
    $req=="all" && $req2!="all" $query="SELECT * FROM vehicles WHERE fueltype='$req2'";
    else if(
    $req!="all" && $req2=="all" $query="SELECT * FROM vehicles WHERE name='$req'";
    else if(
    $req=="all" || $req2=="all" $query="SELECT * FROM vehicles";

    $result=mysql_query($query);
    $num=mysql_numrows($result);

    mysql_query($result);
    mysql_close();

    $i=0;

    for (
    $i$i $num$i++){
        
    $f11=mysql_result($result,$i,"name");
        
    $f12=mysql_result($result,$i,"color");
        
    $f13=mysql_result($result,$i,"capacity");
        
    $f14=mysql_result($result,$i,"fueltype");
        
    echo 
    "$f11." ".$f12." ".$f13." ".$f14.";
    }
    ?>
    the files are same hosted that tested past on select vehicle you can select vehicle.
    i have also made the database for the vehicles.
    thanks


 
Page 2 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Posting Permissions

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