Jump to content

Need to write html to csv but also insert variable in part of the html code


Camyden74

Recommended Posts

I have a form that users input user name, password, and email... all writes to csv fine.  My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv..

 

I need the csv to be this

 

username,password,email,user,category,text with http://sub.domain..com/splash/,something,something

 

here's what i have

 

<?php
if($_POST['formSubmit'] == "Submit")

$varUserName = $_POST['username'];
$varPW = $_POST['PW'];
$varEmail = $_POST['email'];
{
	$fs = fopen("testcsv.csv","a");
	fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',));
	fclose($fs);

	exit;
}
?>

 

and of course I'm getting

 

Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9

<?php
if($_POST['formSubmit'] == "Submit")
    
    $varUserName = $_POST['username'];
    $varPW = $_POST['PW'];
    $varEmail = $_POST['email'];
    {
        $fs = fopen("testcsv.csv","a");
        fputcsv($fs, array("$varUserName","$varPW","$varEmail","user","title",",category","some text '<a href=\"http://$varUserName.url.com/splash/\">site.com</a>'"));
        fclose($fs);
        
        exit;
    }
?>

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.