Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:34:40+00:00 2026-06-18T12:34:40+00:00

I have a website which has a form which submits the data to a

  • 0

I have a website which has a form which submits the data to a database and also sends an email to an email address, which has a random id at the end of the URL which will pull the specific data and display it on a web page. Basically its a valentines message type thing I’m doing

I’ve got that the data being sent to the database and storing perfectly but I’m having issues with pulling the data for some strange reason.

Here’s my code, is there anything you can see that might be causing the issue?

<?php

// since the id is being passed in the url, you will need to declare it using the get method
$rand = $_GET['rand'];
$action = $_GET['action'];

// if an id was sent to the script, then execute it
if ($rand)
{
   // connection vars
   $host = "localhost";
   $user = "***";
   $password = "***";
   $dbname = "***";
   $tablename = "cards";


   $mysql = new mysqli('$host, $user, $password');
   $result = $mysql->query('SELECT * FROM $tablename WHERE rand = $rand');

   while (($row = $result->fetch_assoc()) !== null) {
      print_r($row);

      $youremail = urlencode($row['youremail']);
      $name = urlencode($row['name']);
      $receiveremail = urlencode($row['receiveremail']);
      $message = $row['message'];

      // replace non flash line breaks with the flash \r newline
      $message = str_replace('\n', '\r', $message);
      $message = str_replace('\r\n', '\r', $message);
      $message = str_replace('<br>', '\r', $message);
      $message = str_replace('%0D%0A', '\r', $message);

   }

   // if there was a result echo the stuff below
   if($result)
   {
      // if we have a result we can show the movie and pass the vars along in the strings
  // a set back with this is that you can only pass so much data in the string, think its like 256 characters, but Im not sure.

      echo "Hello, $name <br />";
      echo "$message";
      exit();
   }
   mysql_close();
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:34:41+00:00Added an answer on June 18, 2026 at 12:34 pm

    I would change it to the code below.

    Changed your isset, your while ... loop and removed your false check on $result. I also removed the calls to urlencode you were using, since they do not make any sense if you are going to display these values on the screen. That function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page. See here.

    Lastly, get rid of those quotes in your new mysqli() call.

    <?php
    
    // since the id is being passed in the url, you will need to declare it using the get method
    $action = $_GET['action'];
    
    // if an id was sent to the script, then execute it
    if (isset($_GET['rand'])) {
       $rand = $_GET['rand'];
    
       // connection vars
       $host = "localhost";
       $user = "***";
       $password = "***";
       $dbname = "***";
       $tablename = "cards";
    
       $mysql = new mysqli($host, $user, $password, $dbname);
    
       /* check connection */
       if (mysqli_connect_errno()) {
          printf("Connect failed: %s\n", mysqli_connect_error());
          exit();
       }
    
       $result = $mysql->query("SELECT * FROM $tablename WHERE rand = '$rand'");
    
       while ($row = $result->fetch_assoc()) {
          print_r($row);
    
          $youremail = $row['youremail'];
          $name = $row['name'];
          $receiveremail = $row['receiveremail'];
          $message = $row['message'];
    
          // replace non flash line breaks with the flash \r newline
          $message = str_replace('\n', '\r', $message);
          $message = str_replace('\r\n', '\r', $message);
          $message = str_replace('<br>', '\r', $message);
          $message = str_replace('%0D%0A', '\r', $message);
    
          echo "Hello, $name<br />";
          echo $message;
    
       }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website which has a form in it. I am supposed to
I have a website which has a lot of combo boxes and auto-complete textboxes
I have a website which has so many sub folders in it. I have
For example, I have a website which has a dynamically-generated segment of its dom
I have an ASP.Net website which has a remember me feature for Login page.
I have a running website on wordpress which has been hacked, some file were
I have working website in PHP with a MySQL backend which has several tables
I have a website developed in ASP.NET and VB.NET which has a place for
I have a website on with MVC, which has a dropdown in the masterpage.
I have a solution which has multiple output projects (a website, and admin tool,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.