Jump to content

justlukeyou

Members
  • Posts

    957
  • Joined

  • Last visited

Posts posted by justlukeyou

  1. Hi,

     

    I have search scripts which reads a forms and outputs to /test/searchoutput.php

     

    The form perfectly however I am now trying a form search to a link. For example there is a link on the page called "Green Widgets". One someone clicks the link it performs a search and also outputs to /test/searchoutput.php

     

    The idea is these links will be used directly below the search form to give examples of what users can search for.

     

    Is it possible to do this?

  2. Hi,

     

    Can anyone advise how to count and display the number of terms in a table. I have following code however it connects to the database each time I use which must be wrong.

     

     

    <?php
    
    $link = mysql_connect("localhost", "********", "**********");
    mysql_select_db("*************", $link);
    
    $event_query = mysql_query("
       SELECT
           COUNT(*) AS meeting_room
       FROM
           hostdbase
       WHERE
           category = 'meeting room'
    ");
    $event_row = mysql_fetch_assoc($event_query);
    $categorynumber = $event_row['meeting_room'];  // this is the number 
    
    echo "$categorynumber \n";
    
    ?> 
    

     

    This is an example where on the left handside it displays the number in the table.

     

    https://www.odesk.com/o/jobs/browse/c/software-development/sc/scripts-utilities/

  3. Hi,

     

    The people on here were tremendously helpful in sorting out a join query which featured a query from the domain name. However I am now only trying to echo a list from the database but it also echos the same result multiple times.

     

     

    $query = mysql_query("SELECT eventname, firstname, eventdetails, eventlocation, eventcountry, eventid, eventstart, eventend, logo, company, id, supplierdetails1, eventid
    FROM users
    JOIN eventjobs 
    ORDER BY eventid DESC 
    LIMIT 8	");		
    

     

    I can get this to work (thanks to peoples help on here) but I cant get the above join to work which should be simpler!

     

    			<?php
    $query = mysql_query("SELECT eventname, firstname, eventdetails, eventlocation, eventcountry, eventid, eventstart, eventend, logo, company, id
    FROM users
    JOIN eventjobs ON eventjobs.organiserid = users.id
    WHERE eventjobs.eventid = $eventid LIMIT 10	");	
    
    while($row = mysql_fetch_array($query)) {
    ?>	
    

  4. Hi,

     

    Has anyone gifted/donated money to projects on KickStarter or IndieGogo.

     

    I think they are brilliant sites which are helping people to launch innovative ideas but I cant help think that they are fads and within a few years people will only use them to fund the best and most innovative projects.

     

    Any views on this?

  5. Nope. I thought of a very simple site in which people can add short sentences on there predictions for the future of advertising. People can add absolutely anything.

     

    For example companies in 2016 companies will pay pet owners to shave their logo into their dogs fur so other people can see the logo when they take their dog for a walk. Or a solid and reliable solution for publishers to raise money from mobile internet.

     

    Not sure how useful or interesting the site would be though.

  6. I regularly visit KickStarter and view some of the great ideas which are being funded. I have also noted that 1 or 2 of the funded projects are websites. One which has received $100,000 in crowdfunding.

     

    Is it possible to get crowdfunding for a website idea? Are there any crowdfunding sites which specialise only in websites?

  7. Thanks mate,

     

    I have tried using this but it creates an "mysqli_real_escape_string() expects parameter 1 to be mysqli" error.

     

    I'm not totally what process it is taking. Is it designed to count the number of rows of the $email column?

     

    <?php
    $emailrow = mysqli_query($mysqli, "SELECT * FROM users WHERE email = '" . mysqli_real_escape_string($mysqli, $loginEmail) . "'");
    $row = mysqli_num_rows($emailrow);
    
    if ($row != 0)
    {
    echo "Email taken";
    }
    ?>
    

  8. Hi,

     

    I am trying to publish Tweets onto a page. Does anyone know how it can be done?

     

    I have the following code but it doesn't work.

     

     

     

    	<div class="twittercellwhyev">
    <ol>
    <?	
    
    $feed = json_decode(file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=bbc&count=5'));
    
    
    $pattern = "/http:\/\/(www\.)?([^.]+\.[^.\s]+\.?[^.\s]*)/i";
    $replace = "<a href='http://\\1\\2'>http://\\1\\2</a>";
    
    foreach($feed as $output) {
    
    ?>
    <div class="twittercellinnerev">
    <li>
    <?	
    echo preg_replace($pattern,$replace,$output->text);
    ?>
    </div>
    </li>
    <?	
    
    }
    ?>
    </ol>
    <div class="twitterwhyevimage">
    <a href="http://twitter.com"  rel="nofollow" >
    <img src="/images/followusontwitter.png" alt="Twitter.com"/>
    </a>
    </div>	
    </div>
    

  9. hi,

     

    Can anyone advise please how I can compare a form input with what is in a database and return a message. Am I doing it in the correct process?

     

                               if(($loginEmail) != ($row['email'])) {
                   $errors['incorrectemail'] = "Your email address is incorrect.";
           } 
    

  10. Hmmm...I moved the error messages beneath form so they now only run when the button is pressed however the codes are not comparing the values against the database.

     

    When I enter an email address which is in the database it still returned the message that the email address is incorrect.

     

    Do I need to have a session started to compare an input against the table?

     

    
    			  if(($loginEmail) != ($row['email'])) {
           $errors['incorrectemail'] = "Your email address is incorrect.";
       } 
    

  11. Hi,

     

    I have a login page which I have added a number of error messages. However there is one set which I just cant get to work. The set at the bottom of the post provide the error message as soon as the page is visited.

     

    I'm trying to check if the email address in the database, the password matches and if the character 'Y' is in the "accountconfirmed" column.

     

    Can anyone advise how I can finish these error messages off or why the are displayed as soon as the page is viewed?

     

     

     

    
    <?php
         if ($_SESSION['userLoggedIn'])
    
            session_start();
           $_SESSION['userLoggedIn'] = 0;
           $_SESSION['userEmail'] = '';
           $_SESSION['userID'] = '';
    $_SESSION['userfirstname'] = '';
    $_SESSION['usersurname'] = '';
    
           // Reset errors and success messages
           $errors = array();
           $success = array();
    
    					  if(($password) ==($row['password'])) {
           $errors['incorrectpassword'] = "Your password is incorrect.";
       } 
    
    
    
            if($email != ($row['email'])) 
               $errors['incorrectpassword'] = 'Your passwords did not match.';  
    
    
    
       // Login attempt
       if(isset($_POST['loginSubmit']) && $_POST['loginSubmit'] == 'true')
       {
           $loginEmail = filter_var(trim($_POST['email']), FILTER_VALIDATE_EMAIL);
           $loginPassword    = trim($_POST['password']);
    
    		$accounty = ('y'); 
    
    
           if(count($errors) === 0)
           {
    $loginPassword = md5($loginPassword);
    $query = 'SELECT * FROM users WHERE email = "' . mysql_real_escape_string($loginEmail) . '" AND password = "' . $loginPassword . '" AND accountconfirmed = "' . $accounty . '"LIMIT 1';
               $result = mysql_query($query);
               if (!$result)
               {
                   die('Invalid query: ' . mysql_error());
               }
    
               if(mysql_num_rows($result) === 1)
               {
                   $row = mysql_fetch_assoc($result);
                   $_SESSION['userLoggedIn'] = 1;
                   $_SESSION['userEmail'] = $loginEmail;
                   $_SESSION['userID'] = $row['id'];
                   $_SESSION['userfirstname'] = $row['firstname'];
    			$_SESSION['usersurname'] = $row['surname'];
    
                   header('Location: /index1.php');
                   exit;
               } else {
                   $errors['login'] = 'No user was found with the details provided.1.';
               }
           }
       }
       /*
         The rest of your login page code
       */ 
    
     // Reset errors and success messages  
       $errors = array();  
       $success = array();  
       // Login attempt  
       if(isset($_POST['loginSubmit']) && $_POST['loginSubmit'] == 'true'){  
           $loginEmail = trim($_POST['email']);  
           $loginPassword  = trim($_POST['password']);  
    
       }  
    
    
      	if(!isset($loginEmail) || empty($loginEmail)) {   
           $errors['loginEmail'] = "Please enter your email.";
       }	  
    
    
    
    if(!isset($loginPassword) || empty($loginPassword)) { 
           $errors['loginPassword'] = "Please enter your password.";
       }
    
    
    $accounty = ('Y'); 
    
    
    						  if(($email) != ($row['email'])) {
           $errors['incorrectemail'] = "Your email is incorrect.";
       } 
    
    		  if(($accounty) != ($row['accountconfirmed'])) {
           $errors['confirmedaccount'] = "Your account has not yet been confirmed.  Please request a confirmation email.";
       } 
    
      	 if(($password) != ($row['password'])) {
           $errors['incorrectpassword'] = "Your password is incorrect.";
       } 
    
       ?>    
    
    	  <?php if($errors['incorrectemail']) print '<div class="invalid">' . $errors['incorrectemail'] . ''; ?>	
    	  <?php if($errors['confirmedaccount']) print '<div class="invalid">' . $errors['confirmedaccount'] . ''; ?>   
    	  <?php if($errors['incorrectpassword']) print '<div class="invalid">' . $errors['incorrectpassword'] . ''; ?>   		  
    
    

     

     

     

     

    $accounty = ('Y'); 
    
    
    						  if(($email) != ($row['email'])) {
           $errors['incorrectemail'] = "Your email is incorrect.";
       } 
    
    		  if(($accounty) != ($row['accountconfirmed'])) {
           $errors['confirmedaccount'] = "Your account has not yet been confirmed.  Please request a confirmation email.";
       } 
    
      	 if(($password) != ($row['password'])) {
           $errors['incorrectpassword'] = "Your password is incorrect.";
       } 
    
       ?>    
    
    	  <?php if($errors['incorrectemail']) print '<div class="invalid">' . $errors['incorrectemail'] . ''; ?>	
    	  <?php if($errors['confirmedaccount']) print '<div class="invalid">' . $errors['confirmedaccount'] . ''; ?>   
    	  <?php if($errors['incorrectpassword']) print '<div class="invalid">' . $errors['incorrectpassword'] . ''; ?>   		  
    

     

  12. Thanks,

     

    I have a number of forms which appear to be working fine. However I am stuck on creating one which has no input. The idea is to use it to insert the ID of the user.

     

    I have done a search, this is the closest I have found but it still low on detail.

     

    http://www.designerstalk.com/forums/help-me/53155-php-post-without-input.html

     

    I can echo the two values, its just a matter of inserting them into the database.

     

    
    echo $profileid; 
    echo $followerid; 
    

     

  13. Hi,

     

    I would prefer to continue using PHP. How would I add a form, Im sure almost there with it. The code was working when the page is visited. I just need to make it work only when the button is clicked.

     

    <form>
    <?php
    
    
    
    $followerid = intval($_SESSION['userID']);
           $profileid  = intval($row['id']);
    
    
    
    if(isset($_POST['followbutton']) && $_POST['followbutton'] == 'true'){
    
    
    
    
    if($profileid =  $followerid) {
           $errors['profileid'] = "This is a test error.";
       }
    
    
    
    if(!$errors){
           //Validation of input vars passed, attempt to run query
           //Force vars to be ints to be safe for query statement
    
    
    	    $followerid = intval($_SESSION['userID']);
           $profileid  = intval($row['id']);
    
           $query = "INSERT INTO `follow` (`user_id`, `follow_user_id`) VALUES ('{$profileid}', '{$followerid}')";
           $result = mysql_query($query);
    
    
           if (!$result)
           {
                   $errors[] = "Query: {$query}<br>Error: " . mysql_error();
    
           }
    }	
    }
    
    
    
    ?>
    
    
    
    
          <?php if($errors['profileid']) print '<div class="invalid">' . $errors['profileid'] . ''; ?>  
    
    
    
    </div>
    <div class="followbuttonbox"> 
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?ID=<?php echo $profileid; ?>"><img src="/images/follow.png"  id="followbutton"   /></a>
    <input type="hidden"  id="followbutton" value="true" /> 
    </form>
    

  14. Hi,

     

    I am trying to complete a button which inserts the ID number of the person logged in (followerid) against the ID of the profile page (profileid).

     

    So the person logged in wants to follow the user of the profile they are viewing.

     

    The code had a working inserts the ID as soon as the page is visited. However I am struggling to get it to work only when the button is pressed.

     

    I have tried various vardump and prints but cant seem to get anything to work. Does anyone have any suggestions please?

     

     

    <?php
    
    
    $followerid = intval($_SESSION['userID']);
           $profileid  = intval($row['id']);
    
    
    if(isset($_POST['followbutton']) && $_POST['followbutton'] == 'true'){
    
    
    if($profileid =  $followerid) {
           $errors['profileid'] = "This is a test error.";
       }
    
    
    
    if(!$errors){
           //Validation of input vars passed, attempt to run query
           //Force vars to be ints to be safe for query statement
    
    
    	    $followerid = intval($_SESSION['userID']);
           $profileid  = intval($row['id']);
    
           $query = "INSERT INTO `follow` (`user_id`, `follow_user_id`) VALUES ('{$profileid}', '{$followerid}')";
           $result = mysql_query($query);
    
    
           if (!$result)
           {
                   $errors[] = "Query: {$query}<br>Error: " . mysql_error();
    
           }
    }	
    }
    
    
    
    ?>
    
    
    
    <div class="followbuttonbox"> 
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?ID=<?php echo $profileid; ?>"><img src="/images/follow.png" id="followbutton"   /></a>
    <input type="hidden"  id="followbutton" value="true" /> 
    </div>
    
    
    

  15. Hi,

     

    I have one table called follow:

     

    user_id - the person who is being followed (You view this persons profile)

    follow_user_id - the person who is following the user_id

     

     

    I have a second table called users:

     

    id - the id of the user which is inserted into user_id or follow_user_id

    logo - the logo of the user

     

    I want to display the id and logo of the people following the profile ID and the opposite. The people the the profile ID is following.

     

     

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