New Posts  All Forums:Forum Nav:

Simple PHP help

post #1 of 5
Thread Starter 
I have written a simple script that takes data from an HTML form and sends it to a text file, then redirects back to the form for more data entry. However, I'm trying to insert a line break in text that is printed before the redirect, and cannot seem to make them work. I'm sure it's some simple syntax error I've overlooked, but any help you could provide is very welcome.

Code:

<?php
$File = "data.txt";
$Handle = fopen($File, 'a');
$Data = "\
$Company|";
fwrite($Handle, $Data);
$Data = "$Industry|";
fwrite($Handle, $Data);
$Data = "$First|";
fwrite($Handle, $Data);
$Data = "$Last|";
fwrite($Handle, $Data);
$Data = "$Job|";
fwrite($Handle, $Data);
$Data = "$Street|";
fwrite($Handle, $Data);
$Data = "$City|";
fwrite($Handle, $Data);
$Data = "$State|";
fwrite($Handle, $Data);
$Data = "$Zip|";
fwrite($Handle, $Data);
$Data = "$Phone|";
fwrite($Handle, $Data);
$Data = "$Fax|";
fwrite($Handle, $Data);
$Data = "$Email|";
fwrite($Handle, $Data);
$Data = "$Referrer|";
fwrite($Handle, $Data);
$Data = "$Notes|";
fwrite($Handle, $Data);
print "Data Added, thank you!\
\
If you are not redirected in 2 seconds, please click here: *site URL*";
fclose($Handle);
?>
<script language=javascript>
setTimeout("location.href='*site URL*", 2000);
</script>
Morpheus Mini
(7 items)
 
  
CPUMotherboardGraphicsRAM
i7-6700T SN970 GTX 960 Crucial CT102464BF160B 
Hard DriveOSAudio
Samsung 850 Evo M.2 Windows 10 Pro MOTU Audio Express 
  hide details  
Reply
Morpheus Mini
(7 items)
 
  
CPUMotherboardGraphicsRAM
i7-6700T SN970 GTX 960 Crucial CT102464BF160B 
Hard DriveOSAudio
Samsung 850 Evo M.2 Windows 10 Pro MOTU Audio Express 
  hide details  
Reply
post #2 of 5
Try <br><br> instead of \
\
. \
\
only puts a line break in the HTML code itself, which isn't translated onto the page text.
post #3 of 5
Thread Starter 
Quote:
Originally Posted by SgtSpike View Post
Try <br><br> instead of \
\
. \
\
only puts a line break in the HTML code itself, which isn't translated onto the page text.
That worked perfectly, thank you!
Morpheus Mini
(7 items)
 
  
CPUMotherboardGraphicsRAM
i7-6700T SN970 GTX 960 Crucial CT102464BF160B 
Hard DriveOSAudio
Samsung 850 Evo M.2 Windows 10 Pro MOTU Audio Express 
  hide details  
Reply
Morpheus Mini
(7 items)
 
  
CPUMotherboardGraphicsRAM
i7-6700T SN970 GTX 960 Crucial CT102464BF160B 
Hard DriveOSAudio
Samsung 850 Evo M.2 Windows 10 Pro MOTU Audio Express 
  hide details  
Reply
post #4 of 5
Use <br /> instead of <br> - that way its W3C valid HTML (in other words, better)
Bob
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Athlon 64 3800+ ASUS A8N- SLI Premium XFX GeForce 7800GT Extreme Edition 2GB (2X1GB) Corsair XMS Pro LED TwinX DDR400 
Hard DriveOptical DriveOSMonitor
2x200GB Barracuda SATA RAID0 + 250Gb ATA SONY CDR-RW Ultra speed Windows Vista Home Premium x64 Hanns G 19" widescreen HW191D 
PowerCaseMouse
Antec TruePower 550W Thermaltake Armour Logitech LX5 
  hide details  
Reply
Bob
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Athlon 64 3800+ ASUS A8N- SLI Premium XFX GeForce 7800GT Extreme Edition 2GB (2X1GB) Corsair XMS Pro LED TwinX DDR400 
Hard DriveOptical DriveOSMonitor
2x200GB Barracuda SATA RAID0 + 250Gb ATA SONY CDR-RW Ultra speed Windows Vista Home Premium x64 Hanns G 19" widescreen HW191D 
PowerCaseMouse
Antec TruePower 550W Thermaltake Armour Logitech LX5 
  hide details  
Reply
post #5 of 5
Quote:
Originally Posted by sniperscope View Post
Use <br /> instead of <br> - that way its W3C valid HTML (in other words, better)
***only in XHTML, In HTML you can use empty tags.
Craiginator
(13 items)
 
  
CPUMotherboardGraphicsRAM
e6420 - L712a517 Abit AB9 Pro P965 XFX 7800 GTX 2GB GEIL PC2-8500 Ultra 
Hard DriveOptical DriveOSMonitor
2x Wd 160gb Raid 0 Asus Dvd/Cd-RW Ubuntu / XPlite 22' Acer ws X222W 
KeyboardPowerCaseMouse
G15 Antec 550 True Power Antec 900 G5 
Mouse Pad
Yes Please. 
  hide details  
Reply
Craiginator
(13 items)
 
  
CPUMotherboardGraphicsRAM
e6420 - L712a517 Abit AB9 Pro P965 XFX 7800 GTX 2GB GEIL PC2-8500 Ultra 
Hard DriveOptical DriveOSMonitor
2x Wd 160gb Raid 0 Asus Dvd/Cd-RW Ubuntu / XPlite 22' Acer ws X222W 
KeyboardPowerCaseMouse
G15 Antec 550 True Power Antec 900 G5 
Mouse Pad
Yes Please. 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding