What's new

Help Pahelp po ulit

PeachyPie

Forum Guru
Elite
Joined
Feb 14, 2017
Posts
4,891
Reaction
2,986
Points
1,480
Age
25
pahelp po sana
may ginagawa po kasi akong code, form tapos kelangan mapalabas ko po yung data na galing sa form tapos mavview siya na iisa lang at galing din dapat sa form yung mavview na ininput at yung ininput na yun ay mailalagay sa database at mavview din po ni user

form.php
tapos after nya po mag success submit gusto ko sana mapunta yung ininput ko sa viewform.php na yung ininput mismo ni user ang lalabas pahelp po sa mga mamaw sa coding maraming salamat po
 
Hello! I'd be happy to help you with your code.

To achieve what you described, you can follow these steps:

1. Create a form in form.php where users can input their data. Make sure to set the form's method to "POST" and specify the action as the URL of viewform.php. For example:

HTML:
<form method="POST" action="viewform.php">
  <!-- Input fields for user data -->
  <input type="text" name="input1" placeholder="Enter Input 1" required>
  <input type="text" name="input2" placeholder="Enter Input 2" required>
  <!-- Add more input fields here if needed -->

  <!-- Submit button -->
  <button type="submit">Submit</button>
</form>

2. In viewform.php, retrieve the data submitted from the form using the $_POST superglobal array. You can then display the submitted data and save it to a database. Here's an example:

PHP:
<?php
// Retrieve the submitted data
$input1 = $_POST['input1'];
$input2 = $_POST['input2'];
// Add more variables for additional inputs if needed

// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";
// Add more echo statements for additional inputs if needed

// Save the submitted data to a database
// Replace this with your database connection code
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO your_table (input1, input2) VALUES ('$input1', '$input2')";
// Add more columns and values for additional inputs if needed

if ($conn->query($sql) === TRUE) {
  echo "Data saved to database successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Note: Replace "your_username", "your_password", "your_database", "your_table" with the appropriate values for your database setup.

That's it! When the form is submitted, the data will be displayed on viewform.php and saved to the database. Feel free to modify the code as per your requirements. Let me know if you have any further questions!
 
Hello! I'd be happy to help you with your code.

To achieve what you described, you can follow these steps:

1. Create a form in form.php where users can input their data. Make sure to set the form's method to "POST" and specify the action as the URL of viewform.php. For example:

HTML:
<form method="POST" action="viewform.php">
  <!-- Input fields for user data -->
  <input type="text" name="input1" placeholder="Enter Input 1" required>
  <input type="text" name="input2" placeholder="Enter Input 2" required>
  <!-- Add more input fields here if needed -->

  <!-- Submit button -->
  <button type="submit">Submit</button>
</form>

2. In viewform.php, retrieve the data submitted from the form using the $_POST superglobal array. You can then display the submitted data and save it to a database. Here's an example:

PHP:
<?php
// Retrieve the submitted data
$input1 = $_POST['input1'];
$input2 = $_POST['input2'];
// Add more variables for additional inputs if needed

// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";
// Add more echo statements for additional inputs if needed

// Save the submitted data to a database
// Replace this with your database connection code
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO your_table (input1, input2) VALUES ('$input1', '$input2')";
// Add more columns and values for additional inputs if needed

if ($conn->query($sql) === TRUE) {
  echo "Data saved to database successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Note: Replace "your_username", "your_password", "your_database", "your_table" with the appropriate values for your database setup.

That's it! When the form is submitted, the data will be displayed on viewform.php and saved to the database. Feel free to modify the code as per your requirements. Let me know if you have any further questions!
pano po ipalabas ulit yung data from diyan papunta sa ibang form.php na parang viewdetail.php
 
pano po ipalabas ulit yung data from diyan papunta sa ibang form.php na parang viewdetail.php
To display the submitted data from viewform.php in another form (viewdetail.php), you can pass the data as query parameters in the URL. Here's how you can modify the code:

1. In viewform.php, after saving the data to the database, redirect the user to viewdetail.php with the submitted data as query parameters. Modify the code like this:

PHP:
if ($conn->query($sql) === TRUE) {
  // Redirect to viewdetail.php with query parameters
  header("Location: viewdetail.php?input1=" . urlencode($input1) . "&input2=" . urlencode($input2));
  exit;
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

Note that we are using urlencode() to properly encode the data in the URL.

2. In viewdetail.php, retrieve the query parameters to get the submitted data. Modify the code like this:

PHP:
$input1 = $_GET['input1'];
$input2 = $_GET['input2'];

// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";

Now, when the user submits the form in viewform.php, they will be redirected to viewdetail.php and the submitted data will be displayed.

Please make sure to handle any necessary security and validation checks before displaying and using the data in your application.

Let me know if you have any further questions!
 
To display the submitted data from viewform.php in another form (viewdetail.php), you can pass the data as query parameters in the URL. Here's how you can modify the code:

1. In viewform.php, after saving the data to the database, redirect the user to viewdetail.php with the submitted data as query parameters. Modify the code like this:

PHP:
if ($conn->query($sql) === TRUE) {
  // Redirect to viewdetail.php with query parameters
  header("Location: viewdetail.php?input1=" . urlencode($input1) . "&input2=" . urlencode($input2));
  exit;
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

Note that we are using urlencode() to properly encode the data in the URL.

2. In viewdetail.php, retrieve the query parameters to get the submitted data. Modify the code like this:

PHP:
$input1 = $_GET['input1'];
$input2 = $_GET['input2'];

// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";

Now, when the user submits the form in viewform.php, they will be redirected to viewdetail.php and the submitted data will be displayed.

Please make sure to handle any necessary security and validation checks before displaying and using the data in your application.

Let me know if you have any further questions!
di ko po siya mapagana pwede po yung code from form to viewform to viewdetail
 
di ko po siya mapagana pwede po yung code from form to viewform to viewdetail
I apologize for the confusion earlier. To achieve the desired functionality, you can follow these steps:

1. In form.php, modify the form's action attribute to point to viewform.php. This will ensure that the form data is sent to viewform.php for processing. Also, include hidden input fields to store the form data, which will be passed to viewdetail.php. Here's an example:

form.php:
HTML:
<form method="POST" action="viewform.php">
  <!-- Input fields for user data -->
  <input type="text" name="input1" placeholder="Enter Input 1" required>
  <input type="text" name="input2" placeholder="Enter Input 2" required>
  <!-- Add more input fields here if needed -->

  <!-- Hidden input fields to pass form data to viewdetail.php -->
  <input type="hidden" name="input1_hidden">
  <input type="hidden" name="input2_hidden">
  
  <!-- Submit button -->
  <button type="submit">Submit</button>
</form>

2. In viewform.php, retrieve the form data submitted by the user and store it in variables. Then, redirect to viewdetail.php using the header() function, passing the form data as query parameters in the URL. Here's an example:

viewform.php:
PHP:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  // Retrieve the form data
  $input1 = $_POST['input1'];
  $input2 = $_POST['input2'];

  // Store the form data in hidden input fields
  echo "<input type='hidden' name='input1_hidden' value='$input1'>";
  echo "<input type='hidden' name='input2_hidden' value='$input2'>";

  // Redirect to viewdetail.php with query parameters
  header("Location: viewdetail.php?input1=" . urlencode($input1) . "&input2=" . urlencode($input2));
  exit;
}
?>

3. In viewdetail.php, retrieve the query parameters to get the submitted data. Here's an example:

viewdetail.php:
PHP:
<?php
// Retrieve the query parameters
$input1 = $_GET['input1'];
$input2 = $_GET['input2'];

// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";
?>

Now, when the user submits the form in form.php, the data will be passed to viewform.php, stored in hidden input fields, and then redirected to viewdetail.php. In viewdetail.php, the submitted data will be retrieved from the query parameters and displayed.

Please note that it's important to validate and sanitize the input data to ensure it's safe to use in your application.

I apologize for any confusion caused earlier. Let me know if you have any further questions!
 
I apologize for the confusion earlier. To achieve the desired functionality, you can follow these steps:

1. In form.php, modify the form's action attribute to point to viewform.php. This will ensure that the form data is sent to viewform.php for processing. Also, include hidden input fields to store the form data, which will be passed to viewdetail.php. Here's an example:

form.php:
HTML:
<form method="POST" action="viewform.php">
  <!-- Input fields for user data -->
  <input type="text" name="input1" placeholder="Enter Input 1" required>
  <input type="text" name="input2" placeholder="Enter Input 2" required>
  <!-- Add more input fields here if needed -->

  <!-- Hidden input fields to pass form data to viewdetail.php -->
  <input type="hidden" name="input1_hidden">
  <input type="hidden" name="input2_hidden">
 
  <!-- Submit button -->
  <button type="submit">Submit</button>
</form>

2. In viewform.php, retrieve the form data submitted by the user and store it in variables. Then, redirect to viewdetail.php using the header() function, passing the form data as query parameters in the URL. Here's an example:

viewform.php:
PHP:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  // Retrieve the form data
  $input1 = $_POST['input1'];
  $input2 = $_POST['input2'];

  // Store the form data in hidden input fields
  echo "<input type='hidden' name='input1_hidden' value='$input1'>";
  echo "<input type='hidden' name='input2_hidden' value='$input2'>";

  // Redirect to viewdetail.php with query parameters
  header("Location: viewdetail.php?input1=" . urlencode($input1) . "&input2=" . urlencode($input2));
  exit;
}
?>

3. In viewdetail.php, retrieve the query parameters to get the submitted data. Here's an example:

viewdetail.php:
PHP:
<?php
// Retrieve the query parameters
$input1 = $_GET['input1'];
$input2 = $_GET['input2'];

// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";
?>

Now, when the user submits the form in form.php, the data will be passed to viewform.php, stored in hidden input fields, and then redirected to viewdetail.php. In viewdetail.php, the submitted data will be retrieved from the query parameters and displayed.

Please note that it's important to validate and sanitize the input data to ensure it's safe to use in your application.

I apologize for any confusion caused earlier. Let me know if you have any further questions!
parang nawala po yung ilalagay yung ininput sa database
 
parang nawala po yung ilalagay yung ininput sa database
Apologies for the oversight. To save the input data to the database in viewform.php, you can modify the code as follows:

viewform.php:
```php
<?php
// Retrieve the form data
$input1 = $_POST['input1'];
$input2 = $_POST['input2'];

// Save the data to the database
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO your_table (column1, column2) VALUES ('$input1', '$input2')";
// replace column1, column2, your_table with appropriate values for
 
Apologies for the oversight. To save the input data to the database in viewform.php, you can modify the code as follows:

viewform.php:
```php
<?php
// Retrieve the form data
$input1 = $_POST['input1'];
$input2 = $_POST['input2'];

// Save the data to the database
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO your_table (column1, column2) VALUES ('$input1', '$input2')";
// replace column1, column2, your_table with appropriate values for
what if po si user bumalik sa form.php pero gusto niya ulit tignan yung viewdetail.php na naandun parin yung data na ininput niya nung una tapos gusto niya ulit mag lagay ng panibagong data from form tapos andun parin yung unang detail tapos madadagdag yung pangalawang detail na gusto niyang ilagay
 
what if po si user bumalik sa form.php pero gusto niya ulit tignan yung viewdetail.php na naandun parin yung data na ininput niya nung una tapos gusto niya ulit mag lagay ng panibagong data from form tapos andun parin yung unang detail tapos madadagdag yung pangalawang detail na gusto niyang ilagay
To achieve that functionality, you can modify the code in form.php and viewdetail.php as follows:

form.php:
```php
<?php
// Retrieve the query parameters if available
$input1 = $_GET['input1'] ?? '';
$input2 = $_GET['input2'] ?? '';
?>

<form method="POST" action="viewform.php">
<!-- Input fields for user data -->
<input type="text" name="input1" placeholder="Enter Input 1" value="<?php
 
To achieve that functionality, you can modify the code in form.php and viewdetail.php as follows:

form.php:
```php
<?php
// Retrieve the query parameters if available
$input1 = $_GET['input1'] ?? '';
$input2 = $_GET['input2'] ?? '';
?>

<form method="POST" action="viewform.php">
<!-- Input fields for user data -->
<input type="text" name="input1" placeholder="Enter Input 1" value="<?php
hindi po siya nagana
 

Similar threads

Back
Top