Jump to content

php form help


blesseld

Recommended Posts

Hey,

 

I use a control file to set my meta tags and titles

 

Here's an example

<?php
switch ($sheet_name) {
    case 'page-2'://The page that has $sheet_name equal to the case value, this is the link to tell the page what info to use
        {
        	$page_id = "2";//Standard Page ID
        	$page_location = "home";//Multi Purpose control, Adds Menus, forms or whatever you create.
        	//Header Controls
        	$level_value = "inc";//Used for Path to Stylesheets and Scripts
            $title = "About Us";//Title of Page
            $meta_desc = "About Us";//Description of Page
            $meta_key = "About Us";//Keywords of Page
            //Add Different Elements
            $content_area = "true";
            break;
        }
?>

 

I want to eliminate the need to open this control.php file,  I want to use a form to update the case variables.

 

Any suggestions?  Little bit lost on where I should start since I have only posted to a database.

 

Reason for doing this, everything else is done through an admin panel except this one file and I would like to integrate it with the admin area to eliminate the need to open any files.

 

** side note, this is a template site I built, and does not use a database, crucial for the market im in.

Link to comment
https://forums.phpfreaks.com/topic/192530-php-form-help/
Share on other sites

Hey,

 

Ok,  I am attempting this....  and a bit lost,

 

I am trying to get a form to save to an Array... not sure of this part

Here is the form

		<form method='post' action='admin-submit-meta.php?edit_page=5'>
		<ul class="single">
			<li><label>Title</label><input type='text' maxlength='16' name='updatemeta[]' value='updatemeta' /></li>
			<li><input type='submit' name='submit' /></li>
		</ul>
	</form>

 

I will need 3 or 4 fields... title, keywords, description then on submit if I can get them into an array...

 

foreach($_POST['updatemeta'] as $value){
			         }
                $fp = fopen("content-page-5-meta.php", "w");
			fwrite($fp,serialize($value));

 

Saves to the file ok

 

Then before I include my template-top

 

// Reading the data
$readmeta = file_get_contents('inc/admin/content-page-5-meta.php');
$metadata = unserialize($readmeta);

// Now you can access those normally like arrays:
echo $metadata['updatemeta'];

// Or if you want those to be variables you can use extract function
extract($metadata);
echo $updatemeta;
$title = "$updatemeta";

 

I include my template-top with the html <head>  and set the title with

<title><?=$title?></title>

 

I am getting this error

 

Warning: extract() [function.extract]: First argument should be an array in /home/insidegu/public_html/contact.php on line 19

 

Any Ideas, I know it has something to do with the array,  but i never understood them so I am trying to tackle this.

 

I used this as a resources

// set and write data for example
$store = array(
            'name' => 'John',
            'age' => 29,
            'location' => 'Finland',
            'hobby' => 'music'
        );
        
$fp = fopen('info.txt','w');

fwrite($fp,serialize($store));


// Reading the data
$infotxt = file_get_contents('info.txt');
$info = unserialize($infotxt);


// Now you can access those normally like arrays:
echo $info['name'];
echo $info['age'];
echo $info['location'];
echo $info['hobby'];

// Or if you want those to be variables you can use extract function
extract($info);

echo $name;
echo $age;
... 

 

And found this other thread

http://www.phpfreaks.com/forums/index.php?topic=234067.0

 

Tried to figure it out... now need a bit of assistance,

 

Any help is greatly appreciated.

thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/192530-php-form-help/#findComment-1014878
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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