Jump to content

mahenda

Members
  • Content Count

    97
  • Joined

  • Last visited

Posts posted by mahenda


  1. //my php code sample
    <?php
    include_once('con.php');
    if(isset($_POST['username'])){
        $message = [];
        if(empty($_POST['username'])){
            $message['username'] = 'username required';
        }
    	#some validation continue...
        $data = $_POST['username'];
        if (count($errors) === 0){
     		#ccode...
    		$message['username'] = 'success your name saved';
        }
    }
    ?>
    //my jquery ajax
     $('.username').click(function() {
            $.ajax({
                url: 'user.php',
                method: 'POST',
                data: $('.user').serialize(),
                success: function(data) {
                     swal('Wow!','success message from php','success');
                },
                error: function(data) {
                     swal('Oops!','error message from php','error');
                }
            });
            return false;
        });

     


  2. 8 hours ago, gw1500se said:

    You need to use strtotime. It will create a time stamp then you compare the time stamps directly.

    
    if(strtotime("+15 minutes") < strtotime($some_variable)) {

     

     

    8 hours ago, gw1500se said:

    You need to use strtotime. It will create a time stamp then you compare the time stamps directly.

    
    if(strtotime("+15 minutes") < strtotime($some_variable)) {

     

    what if user click the link by tomorrow at the same time


  3. how to calculate the difference between the current datetime  from the stored one(ie date_field = 2020-08-09 23:13:06) in order to compare with 15min, i mean  if the resulted time exceed 15 min and not the same day(date) the provided link will show  expire message.

    i.e $some_variable = $date_in_db - current_date;

    if((time() - $some_variable > 15*60) && not the same day or the same day){

    echo 'the link has expired';

    }

     


  4. 20 hours ago, requinix said:

    You have to put something in your query so that you can tell where each result is coming from. Then use that to output the correct link.

    My query look like this

    SELECT pr_id, pr_name FROM pr WHERE pr_name LIKE :q UNION SELECT pt_id, pt_name FROM pt WHERE pt_name LIKE :q

     

    The problem is when we search it combine all pr_id and pt_id in a single column and all I'd can be retrieved by using pr_id.

    So when user click the link which carry pt_id it redirect to the page with pr_id details.

    Help


  5. I have two table in my database combined by using  UNION, when it come to searching via search form, all data are retrieved as expected, but the problem come when i click the link that has the data from second table it redirecting to the page with first table details.

    Assume i have  retrieved data using while loop and the UNION.

     while($search = $query->fetch()) {?> 
           <div>
           	<a href="pageone.php?po=<?php echo $search['pr_id'];?>">Read More...</a>             
           </div>
    <?php }?>
    
    //the result become
    
    <a href="pageone.php?po=1">Read More...</a>             
    <a href="pageone.php?pt=3">Read More...</a>
    
    //But what if data come from both first and second table in a database, i want the link become to be as
    
    <a href="pageone.php?po=1">Read More...</a>             
    <a href="pagetwo.php?pt=3">Read More...</a>
    
    // any idea please

     

     


  6. How can I add parsley attributes /rules in custom.js file instead of adding them in form field

    I have

    <form id="register">

    <input type="email" name="email" id="email">

    </form>

    //Js

    $("#register"). parsley (

    //How to write all validation here not inside the input element. 

    );


  7. I'm facing trouble on check box when register form is submitted without check the check button, but when the button is checked the error disappear .

    can you give me idea why and how to solve this issue.

    I saw many sites with  such kind of button on registration form please any one who can solve this.


  8. Is jquery/Ajax better than real/raw PHP for form validation ?!

    What if JavaScript is turned off on the browser?!

    why after someone refreshing a page on the browser, the variables used to echo error after invalid data is being submitted will return the undefined variables error?!

    And how to handle form validation including an empty form field, maximum amount of value entered and so on


  9. 36 minutes ago, mac_gyver said:

    what output do you get and if it's a blank page, what does the 'view source' of the page in your browser show?

    either the output is hidden in the 'view source' or the code isn't being executed. since you apparently are getting the data inserted,  it's possible you are 'seeing' the result of a double page request, especially since you are using a get request to do this rather than a post method form

    Thanks you guys I solved the problem.

    It was the view part not a PHP code


  10. 41 minutes ago, Barand said:

    What happens if you actually test if the execute() worked?

    Instead of

    
    $subscribe->execute([$name, $email]); 
    if($subscribe){
        echo ....

    try

    
     
    if ($subscribe->execute([$name, $email])) {
        echo ....

     

    Here the data is sent in a database but the 

    echo '<span>Hi '.$name.'</b>,subscription is now active.</span>';

    doesn't work. In else statement


  11. 38 minutes ago, ginerjm said:

    Is the echo for "not being inserted" showing up?

    PS - your check to see if a row is returned matching your $email could also be done by simply checking the number of rows returned.  Plus - using the input value directly could compare a bad input value against the most-likely 'good' value saved in your db if your user is providing 'bad' input.

    The first echo after

     

    54 minutes ago, mahenda said:

    if($email == $row['email']){

    The echo after the above code is show and it is okey but the problem is there on the echo after insertion of data the echo doesn't show the given success message on the page 


  12. <?php
    global $con;
    $name = $_GET['name'];
    $email = $_GET['email'];
    if((!empty($name)) && (!empty($email))){
        $check = $con->prepare('SELECT email FROM subs WHERE email = ?');
        $check->execute([$email]);
        $row = $check->fetch();
        if($email == $row['email']){
            echo '<span>'.$email.' already in database, try another email!.</span>';
        }else{
            $subscribe = $con->prepare('INSERT INTO subs (name, email) VALUES (?, ?)');
            $subscribe->execute([$name, $email]);
            if($subscribe){
                echo '<span>Hi '.$name.'</b>,subscription is now active.</span>';
            }else{
                echo '<span>Try again</span>';
            }
        }
    }else{
        echo '<span>please enter something</span>';
    }
    ?>

    the problem found at if($subscribe){

    //the echo not showing the span element when data is inserted 

    }

     

    any help please?


  13. 16 minutes ago, requinix said:

    I said that a few days ago. Have you done it? Have you made it so that /article?title=this-is-new-product works?

     

    16 minutes ago, requinix said:

    I said that a few days ago. Have you done it? Have you made it so that /article?title=this-is-new-product works?

    no i dont want this  /article/this-is-new-product to /article?title=this-is-new-product

    i want this 

     /article?title=this%20is%20new%20product to be  /article/this-is-new-product

    check here

    RewriteRule ^([a-zA-Z0-9]+)$ article.php?title=$1
    RewriteRule ^([a-zA-Z0-9]+)/$ article.php?title=$1


  14. On 11/1/2019 at 2:00 PM, requinix said:

    That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do.

     

    On 11/1/2019 at 2:00 PM, requinix said:

    That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do.

     

    On 11/1/2019 at 2:00 PM, requinix said:

    That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do.

    i dont have that, but i have the link like below if you have an example of an .htaccess to make a clean url please help me.

    //the title
    <div class="title">
    <a href="<?php echo 'article? title='.$title['title'];?>" ><?php echo $title['title'];?></a>
    </div>

    which produce this after being clicked

    http://localhost/mysite/article?title=this is new%20product

    but i want to get this

    http://localhost/mysite/article/this-is-new-product

    if i try to use str_replace then there is no result shown after clicking the link
     


  15. On 10/29/2019 at 11:09 PM, requinix said:
    On 10/29/2019 at 11:09 PM, requinix said:

    One sure-fire way to get people to not help you is to tag them and plead for their help.

    What RewriteRule have you tried to do this?

    "Can't" do that with just mod_rewrite. The problem is that you want to replace spaces with hyphens. What you can do is rewrite /article/this-is-new-product to /article?title=this-is-new-product. So first make your article.php support that. When that's ready,

    What RewriteRule have you tried to do this?

    One sure-fire way to get people to not help you is to tag them and plead for their help.

    What RewriteRule have you tried to do this?

    "Can't" do that with just mod_rewrite. The problem is that you want to replace spaces with hyphens. What you can do is rewrite /article/this-is-new-product to /article?title=this-is-new-product. So first make your article.php support that. When that's ready,

    What RewriteRule have you tried to do this?

    check on the htacess above

×
×
  • 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.