Jump to content

jpergega

Members
  • Posts

    33
  • Joined

  • Last visited

Posts posted by jpergega

  1. Hi

     

    I have a login form but when I click on the submit button it does nothing. I looked up and some people said is to do with JQuery but I don't know JQuery at all. Could someone please tell me how can I make the submit button work please?

     

    Here is my code:

            <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">                                <div class="panel panel-info" >                    <div class="panel-heading">                        <div class="panel-title">Sign In</div>                        <div style="float:right; font-size: 80%; position: relative; top:-10px"><a href="#">Forgot password?</a></div>                    </div>                         <div style="padding-top:30px" class="panel-body" >                        <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>                                                    <form id="loginform" class="form-horizontal" action="signup.php" method="POST">                                                                <div style="margin-bottom: 25px" class="input-group">                                        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>                                        <input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username">                                                                            </div>                                                            <div style="margin-bottom: 25px" class="input-group">                                        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>                                        <input id="login-password" type="password" class="form-control" name="password" placeholder="password">                                    </div>                        <div style="margin-bottom: 25px" class="input-group"> 						<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>                        <select id="type" class="form-control" Placeholder="Select option.."name="permission">            			<option value="Student" selected="selected">Student</option>            			<option value="Staff">Staff</option>            			<option value="Admin">Administrator</option>            			</select>                       </div>                                                   <div class="input-group">                                      <div class="checkbox">                                        <label>                                          <input id="login-remember" type="checkbox" name="remember" value="1">Remember me</label>                                      </div>                                    </div>                                <div style="margin-top:10px" class="form-group">                                    <!-- Button -->                                    <div class="col-sm-12 controls">                                      <input type="button" name="submit" value="Sign in">                                      <!--<a id="btn-fblogin" href="" class="btn btn-primary">Login with Facebook</a>-->                                    </div>                                </div>                                <div class="form-group">                                    <div class="col-md-12 control">                                        <div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >                                            Don't have an account!                                         <a href="#" onClick="$('#loginbox').hide(); $('#signupbox').show()">                                            Sign Up Here                                        </a>                                        </div>                                    </div>                                </div>                                </form>                             </div>                                         </div>          </div>
  2. Hi,

     

    I have a table contains 2 foreign keys and I am having trouble inserting a record to this table. Below is my code:

    $query = "            INSERT INTO reply (			foreignKey1_id,foreignKey2_id,message,date_Created            )            VALUES (             '$foreignKey1','$foreignkey2', '$msg',NOW()            )";

    This is the error message: Cannot add or update a child row: a foreign key constraint fails....................

     

    I have used the disable foreign key checks but still getting this error. Is there other way to make this work?

     

    Thanks

     

     

  3. Hi,

     

    I want to add new records to a table and there is a foreign key in this table, so I set the disable foreign key via phpmyadmin export, then I re-imported back to the database. However, I am still getting the cannot add or update a child table message. Please tell me what I'm doing wrong here. Thanks

     

    $postNT = "
    INSERT INTO `tbl_A` (
    id, message, date,
    )
    VALUES (
    '{$_SESSION['id']}', '{$msg}',
    NOW())";
  4. Thanks for this

     

    I am using WAMP Server

    I changed my files' extension to .php and is now giving me error message inside the image frame says: call to undefined function functionName()

     

    Here is how I call the function :

    <img class="img-responsive" src="<?php include 'functions.php'; getImage(); ?>" >

  5. Hi

     

    I am trying to fetch photos from the database but it doesn't show on the website page:

     

    PHP -

     

    function getImage(){
    $query = "SELECT * FROM imgLib WHERE id=$_SESSION['id']";
    $result = mysqli_query($con, $query);
    while($row = mysqli_fetch_assoc($result)){
    echo $row['img'];
    }
    }
    HTML -
    <img class="img-responsive" src="<?php getImage(); ?>" >
    Result on Website page -
    see attachment
    Thanks

    post-171792-0-51366100-1423396297_thumb.png

  6. Hi

    My query is like this and is saying there is an syntax error near 'cusomter_id')}' what am I doing wrong here?

    $query = "
    INSERT INTO `imglib` (
    `img_name`, `img_type`, `img_size`, `img`,`customer_id`
    )
    VALUES (
    '{$name}', '{$mime}', {$size}, '{$data}','{SELECT(customer_id FROM customer WHERE customer_id='cusomter_id')}'
    )";
    Thanks
  7. Hi

     

    My query is like this and is saying there is an syntax error near 'cusomter_id')}' what am I doing wrong here?

     

    $query = "
    INSERT INTO `imglib` (
    `img_name`, `img_type`, `img_size`, `img`,`customer_id`
    )
    VALUES (
    '{$name}', '{$mime}', {$size}, '{$data}','{SELECT(customer_id FROM customer WHERE customer_id='cusomter_id')}'
    )";
    Thanks
  8. Right now my timeline chart doesn't show up at all in my web page I am not sure what is wrong with my code is not given me any errors.

    I think this could be something to do with the date format I set but I am not sure. I double checked the date format and the one I am using it is matching with my database.

    I would be grateful if you could point out where when wrong. Thanks

    <?php$sth = "SELECT * FROM goal WHERE account_id =$account_id";$result4 = mysqli_query($con,$sth) or die(mysqli_error());$rows = array();$flag = true;$table = array();$table['cols'] = array(array('type' => 'string', 'label' => 'goalName'),array('type' => 'date', 'label' => 'starts'),array('type' => 'date', 'label' => 'finish'));//$rows = array();while($rows = mysqli_fetch_assoc($result4)) {$temp = array();$starts = date("Y-m-d");$finish = date("Y-m-d");$temp[] = array('v' => (string) $rows['goalName']);$temp[] = array('v' => (string) $rows['starts']);$temp[] = array('v' => (string) $rows['finish']);$rows[] = array('c' => $temp);}$table['rows'] = $rows;$jsonTable = json_encode($table);//echo $jsonTable;?><script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules': [{'name':'visualization','version':'1','packages':['timeline']}]}"></script><script type="text/javascript">google.setOnLoadCallback(drawChart);function drawChart() {var container = document.getElementById('example3.1');var chart = new google.visualization.Timeline(container);var dataTable = new google.visualization.DataTable();var data = "" google.visualization.DataTable(<?php echo json_encode($table, JSON_NUMERIC_CHECK); ?>);var options = {title: 'Progress',is3D: truevar options = {timeline: { colorByRowLabel: true }};chart.draw(dataTable, options);}</script>

  9. Hi

     

    I am trying to insert a query output which displayed in a dropdown box to a table in mysql.

     

    Right now the problem is that I am getting this error: Error:Unknown column 'A' in 'where clause'

    (I think is probably something to do with the name being given to the select and the query output name, but I don't know how to sort this out because I have tweaked around and nothing works. Please help! Thanks )

     

    Here is my code:

     

    <select name="staff_id">

    <option selected="selected" value ="<?php echo $row["staff_id"];?>"><?php echo $row["staff_id"];?></option>
    </select>
    <?php
    if(isset($_POST['save'])){
    $staff_id = $_POST['staff_id'];
    //inserting data order
    $order2 = "INSERT INTO goal(staff_id) SELECT staff_id FROM staff WHERE staff_id =$staff_id";
    if(!mysqli_query($con,$order2)){
    die('Error:'. mysqli_error($con));
    }
    ?>

     

  10. If you want to load the tasks for one particular user you probably have to check that useraccount.account_id has one particular value. I can't be sure, though, since I don't know the structure of your database.

     

    Hi

     

    Here is my tables will you be able to tell me how to display whatever is belongs to this student? Thanks

     

    CREATE TABLE userAccount (
    account_id SMALLINT NOT NULL AUTO_INCREMENT,
    username varchar(7) NOT NULL,
    password varchar(8) NOT NULL,
    firstname varchar(50) NOT NULL,
    surname varchar (30) NOT NULL,
    email varchar(50) NOT NULL,
    permission ENUM('Student', 'Staff') NOT NULL,
    PRIMARY KEY (account_id)
    )

     

    CREATE TABLE staff (
    staff_id SMALLINT NOT NULL AUTO_INCREMENT,
    account_id SMALLINT NOT NULL,
    PRIMARY KEY (staff_id),
    FOREIGN KEY (account_id) REFERENCES userAccount(account_id)
    )

     

    CREATE TABLE IF NOT EXISTS `task` (
    `task_id` smallint(6) NOT NULL AUTO_INCREMENT,
    `taskName` varchar(100) NOT NULL,
    `description` varchar(300) NOT NULL,
    `starts` date NOT NULL,
    `finish` date NOT NULL,
    `progress` varchar(300) NOT NULL,
    `status` varchar(10) NOT NULL,
    `account_id` smallint(6) NOT NULL,
    `staff_id` varchar(100) DEFAULT NULL,
    PRIMARY KEY (`task_id`),
    KEY `account_id` (`account_id`),
    KEY `staff_id` (`staff_id`)
    )
  11. You need to make the correct SQL query if you want the correct data. What does your query look like?

     

    Thanks My query is this:

    <?php
    if(isset($_SESSION['account_id']))
    {
    $account_id = $_SESSION['account_id'];
    $query = "SELECT staff.staff_id, staff.account_id, task.task_id, task.staff_id, useraccount.username, useraccount.firstname, useraccount.surname, useraccount.account_id FROM useraccount,staff, task WHERE task.account_id=useraccount.account_id AND task.staff_id=staff.staff_id AND staff.account_id=$account_id";
    $result= mysqli_query($con,$query);
  12. Hi

     

    I have a form and I only want the user to use it only once. How can I disable this form permanently once been submitted? Thanks

     

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <label>Unique Ref:<input name="reference" type="text" size="30"/>
    <br><input type="submit" name="save" value="Save"/>
    </form>
  13. Hi

     

    My system has 2 different accounts staff and student.

     

    Both users account details(login, names) are stored in the useraccount table.

    Student has another table called Task.

     

    I logged in as a staff and I want to view a student's tasks by clicking on the view link next to their name.

     

    Right now if I click on a student's view link it will just bring up everything in the task table, but that is not what I want it should only display whatever is belongs to this student. I am not sure how to do this could you please help?

     

    <?php
    while($row = mysqli_fetch_array($result)){
    ?>
    <tr>
    <td><?php echo $row['username'] ; ?></td>
    <td><?php echo $row['firstname'] ; ?></td>
    <td><?php echo $row['surname'] ; ?></td>
    <td><a href="viewStudent.php<?php echo '?task_id='.$row['task.account_id']; ?>">View Account</a></td>
    <?php
    }
    }

    ?>

  14. where's the code you changed? We can't tell what you did wrong without it.

     

    Are you checking the values of $curdate and $row['finish']? Do you know what they actually are so you can tell if they should or shouldn't be equal?

    Earlier I changed to this $today = date("Y-m-d H:i:s");

    Now I have got rid of the time $today = date("Y-m-d"); is working now Thanks

  15. You should read the documentation on PHP's date() function. As you have it written right now today's date would be represented as 14141414/0303/2020

    Thanks I read the date function link you provided and I have changed the date format but still nothing happened. Any other suggestions that I am doing wrong?

  16. Hi I have a alert box here that want to pop up when a user is logged into their account. The alert box will tell the user there is a expired task.

     

    Here is my code but is not doing anything please could you tell me what is wrong with it? because is not showing any errors. Thanks

     

    <?php
    if(isset($_SESSION['account_id']))
    {
    $account_id = $_SESSION['account_id'];
    $curdate = date('yyyy/mm/dd');
    $query4 = "select finish from task WHERE account_id=$account_id";
    $result4= mysqli_query($con,$query4);
    while($row = mysqli_fetch_array($result4)){
    if($row['finish'] == $curdate)
    {
    echo '<script language="javascript">alert("Your task had been expired.")</script>';
    }
    }
    }

    ?>

×
×
  • Create New...