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

  • SEARCH
  • Home
  • 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 7981949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:31:53+00:00 2026-06-04T10:31:53+00:00

I would like to submit a form and get the info written into the

  • 0

I would like to submit a form and get the info written into the CSV file and stored in the hosting. And every new form should add a new line in csv. Also, lets say I have few groups that a user can join – A,b,c,d,e. How do I make it so if user choose to join 2 or three groups(1,2 and 3rd groups), it is going to store this info as 123 in the same cell. Following is my HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reg</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="post.php">
<table width="597" class="formatTblClass">
<tr>
<th colspan="4"></th>
</tr>
<tr>
<td width="99"><span>First Name</span></td>
<td width="217"><input class="" type="text" name="fn" id="fn" /></td>
<td width="99"><span>Last Name</span></td>
<td width="211"><input class="" name="ln" type="text" id="ln" /></td>
</tr>
<tr>
  <td>Phone</td>
  <td><input class="" type="text" name="phone" id="phone" /></td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td colspan="4">Check groups that you would like to receive updates about</td>
  </tr>
<tr>
  <td><input name="1" type="checkbox" id="1" value="a" /></td>
  <td>A</td>
  <td><input name="4" type="checkbox" id="4" value="b" /></td>
  <td>B</td>
</tr>
<tr>
  <td><input name="2" type="checkbox" id="2" value="c" /></td>
  <td>C</td>
  <td><input name="5" type="checkbox" id="5" value="d" /></td>
  <td>D</td>
</tr>
<tr>
  <td><input name="3" type="checkbox" id="3" value="e" /></td>
  <td>E</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td colspan="4">
  <div align="center">
  <input type="submit" name="Submit" id="Submit" value="Submit" />
  <input type="reset" name="Reset" id="button" value="Reset" />
  </div></td>
</tr>
</table>
</form>
</body>
</html>

and this is my post.php file:

<?php
$fn = $_POST['fn'];
$ln = $_POST['ln'];
$phone = $_POST['phone'];
$1 = (isset($_POST['1'])) ? $_POST['1'] : 'No';
$2 = (isset($_POST['2'])) ? $_POST['2'] : 'No';
$3 = (isset($_POST['3'])) ? $_POST['3'] : 'No';
$4 = (isset($_POST['4'])) ? $_POST['4'] : 'No';
$5 = (isset($_POST['5'])) ? $_POST['5'] : 'No';

//validate

if(empty($fn) || empty($ln) || empty($phone)){//show the form
$message = 'Fill in areas in red!';
$aClass = 'errorClass';

//this is where the creating of the csv takes place
$cvsData = $phone . "," . $fn . "," . $ln . "," . $phone . "," . $1 ."\n";

$fp = fopen("formTest.csv","a"); // $fp is now the file pointer to file $filename

if($fp){
fwrite($fp,$cvsData); // Write information to the file
fclose($fp); // Close the file
?>

When I submit the form, I get a blank page. What is wrong? index.html, post.php and testForm.csv are all in the same folder.

  • 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-04T10:31:56+00:00Added an answer on June 4, 2026 at 10:31 am

    Your missing a closing bracket for

    if($fp){ and if(empty($fn) || empty($ln) || empty($phone)){

    You should enable error_reporting(E_ALL) it will show the error and the use of

    $fn = $_POST['fn'];
    $ln = $_POST['ln'];
    $phone = $_POST['phone'];
    

    as undefined if the forms not posted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if it is possible to submit a flash form
I would like to have a form that can submit to two different action
In my symfony application I would like to get form model object before calling
I want the user to submit a form and get a pdf back. Like
I would like to trigger an ajax call/object instantiation when i submit a form.
I have an ajax form that I would like to submit, and the response
I would like to submit a form, specifically an input field to a URL
I have a form that I would like to submit to a component for
I am using jQuery 1.6 and I would like to submit a form by
I would like to use replace the value of a submit button with Loading&hellip;

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.