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 8444541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:25:06+00:00 2026-06-10T09:25:06+00:00

Okay, so here’s what I want to do (NOTE: I’m stil new to PHP):

  • 0

Okay, so here’s what I want to do (NOTE: I’m stil new to PHP):

I have a registration form for movies/series etc. The data from the filled form is then registered (register.php) and sent to a MySQL database, which is working fine. Here comes the but: I also want, in the same register file (register.php), the data to be stored in an existing XML-file (data.xml). Important here is that every successfully submitted form is stored in the same XML-file (data.xml).

I display all registered “movies” in a HTML-table through a while-loop, which now collects the data from my database. I’m also begging for help to, somewhere outside the table, add a button which generate/display the content of the XML-file in a new tab(?). Not right-clicking to view source, since the table data is collected from MySQL this is impossible.

Here’s what I have so far (this manages to save each submission in data.xml but replaces if another submission is made – I want to add NOT replace):

First off, index.php:

<form enctype="multipart/form-data" action="core/register.php" method="post" autocomplete="true">
    <p><input type="text" name="name" placeholder="Program name" /></p>
    <p><input type="date" name="date" placeholder="Program date" /></p>
    <p><input type="time" name="time" placeholder="Program time" /></p>
    <p><input type="text" name="bline" placeholder="B-line" /></textarea></p>
    <p><textarea name="synopsis" placeholder="Program synopsis" /></textarea></p>
    <p><textarea name="leadtext" placeholder="Lead text" /></textarea></p>
    <p><input type="url" name="url" placeholder="URL" /></p>
    <p><input type="submit" value="Register" name="register" /></p>
</form>

Next up, data.xml:

<?xml version="1.0" encoding="UTF-8"?>
<programs>
    <program>
        <name></name>
        <date></date>
        <start_time></start_time>
        <b-line></b-line>
        <synopsis></synopsis>
        <leadtext></leadtext>
        <url></url>
    </program>
</programs>

Finally, register.php:

require_once('db.php');

$str = '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="xsl.xsl"?><programs></programs>';
$xml = simplexml_load_string($str);

$name = $_POST['name'];
$date = $_POST['date'];
$time = $_POST['time'];
$bline = $_POST['bline'];
$synopsis = $_POST['synopsis'];
$leadtext = $_POST['leadtext'];
$url = $_POST['url'];

$name = htmlentities($name, ENT_COMPAT, 'UTF-8', false);
$date = htmlentities($date, ENT_COMPAT, 'UTF-8', false);
$time = htmlentities($time, ENT_COMPAT, 'UTF-8', false);
$bline = htmlentities($bline, ENT_COMPAT, 'UTF-8', false);
$synopsis = htmlentities($synopsis, ENT_COMPAT, 'UTF-8', false);
$leadtext = htmlentities($leadtext, ENT_COMPAT, 'UTF-8', false);
$url = htmlentities($url, ENT_COMPAT, 'UTF-8', false);

$xml->program->addChild('name', $name);
$xml->program->addChild('date', $date);
$xml->program->addChild('start_time', $time);
$xml->program->addChild('b-line', $bline);
$xml->program->addChild('synopsis', $synopsis);
$xml->program->addChild('leadtext', $leadtext);
$xml->program->addChild('url', $url);

$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$doc->preserveWhiteSpace = true;
$doc->loadXML($xml->asXML(), LIBXML_NOBLANKS);
$doc->save('data.xml');

I have searched for hours without finding exactly what I’m looking for. Also tried my best to try plenty of my own “not-working-solutions”. Also, I picked out the parts of my code that’s relevant for answers on this matter.

  • 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-10T09:25:08+00:00Added an answer on June 10, 2026 at 9:25 am

    You need to make the program node permanent by assigning it a value like so:

    $xml->program = "";
    

    Add that line just before adding child nodes to it:

    $xml->program = "";
    $xml->program->addChild('name', $name);
    $xml->program->addChild('date', $date);
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so here is my database: I have a page on my .net form
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay here is what I'm trying to do: I have a model object that
Okay so here's, the scenario I have a thumbnail that contains an artists profile
Okay so here is what I want to do. I want to add a
Okay basically here's where I'm at. I have a list of PropertyDescriptor objects. These
Okay, here's the rundown. I'm developing a video hosting site with PHP and jQuery
Okay here is what I'm, trying to do I want to escape the period
Okay so here is the problem I am having. I have several unit tests
Okay so here's the thing: I have a linq query which loads approx. 1000

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.