Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › PHP Form data retention
New Posts  All Forums:Forum Nav:

PHP Form data retention - Page 4

post #31 of 38
Thread Starter 
Okay, I'm still not getting it to work properly.

This is my original code for the .php file that controlled the input values and where the email is sent to and so on.

So what I'm gathering, is that I somehow need to split this code in between "contact.php" and "contact-thanks.php"

Also, I still want to ensure that I keep any entered values (e.g., name, email, subject, etc.).
Code:
<?php
$mailto = 'info@regibase.us' ;
$subject = "Contact form message - RBF-US" ;
$formurl = "http://www.regibase.us/contact-error.php" ;
$errorurl = "http://www.regibase.us/contact-error.php" ;
$thankyouurl = "http://www.regibase.us/contact-thanks.php" ;

 
// -------------------- END OF CONFIGURABLE SECTION ---------------
 
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$subject = $_POST['subject'] ;
$comments = $_POST['comments'] ;
$spam=$_POST['spam'] ;
$http_referrer = getenv( "HTTP_REFERER" );
 
if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit ;
}
if (empty($name) || empty($email) || empty($subject) || empty($comments) || $spam!="78260") {
   header( "Location: $errorurl" );
   exit ;
}

$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
$subject = strtok( $subject, "\r\n" );
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
 
$messageproper ="---------- Sent VIA Contact Page (TFPS) ----------\n\n" . "\nSent by : " . $name . "\nEmail : " . $email . "\nSubject : " . $subject . "\n\n\nMessage : " . $comments;
 
mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php 2.04" );
header( "Location: $thankyouurl" );
exit ;
?>

Also, without the HTML that draws the rest of the page, here is the actual form code embedded within:
Code:
<form action="contact_thanks.php" method="POST">
  
  <fieldset>
    
  <legend>Your contact information</legend>
    
  <p style="margin-left:70px">
    
  <label><strong>Name:</strong></label>
  <span class="asterisk"><font color="#FF0000">*</font></span><br />
    
  <input name="name" type="text" class="sub_bg3" value="<?php echo $_POST['name'];?>"  />

</p>
    
  <p style="margin-left:70px">
    
  <label><strong>Email:</strong></label>
  <span class="asterisk"><font color="#FF0000">*</font></span><br />
    
  <input name="email" type="text" class="sub_bg3" value="<?php echo $_POST['email'];?>" />
    
  </p>
    
  <p style="margin-left:70px">
    
  <label><strong>Subject:</strong></label>
  <span class="asterisk"><font color="#FF0000">*</font></span><br />
    
  <input name="subject" type="text" class="sub_bg3" value="<?php echo $_POST['subject'];?>" />
    
  </p>
  <p class="asterisk" style="margin-left:70px; color: #F00;">* <span class="ital">required entries</span></p>
  <br />
    
  </fieldset>
                                                                                    
  <fieldset>
    
  <legend>Your message</legend>
    
  <p style="margin-left:70px">
    
  <label><strong>Message:</strong></label>
  <br />
    
  <textarea name="comments" cols="50" rows="7" class="sub_bg3" value="<?php echo $_POST['comments'];?>"></textarea>
    
  </p>
    
  <p style="margin-left:70px"><img src="images/LockIcon.png" width="15" height="20" /> Security pass-code = <strong style="color: #0000FF">78260</strong><br />
    <strong>Please enter the <strong style="color: #0000ff">blue</strong> pass-code  provided above:</strong><br />
    
  <input name="spam" type="text" class="sub_bg3" value="" />
    
  </p>
    
  <p style="margin-left:70px">
    
  <input class="button" name="submit" type="submit" value="Send" />

</p>
    
  </fieldset>
                                                                                    
</form>

Edited by VaiFanatic - 8/6/12 at 11:58pm
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
post #32 of 38
on your main contact page add:
Code:
<?php
$secureid = rand(500, 9999); //generates a random integer from 500 to 9999, can be edited to anything
?>
...
<form>
...
<input hidden="hidden" value="<?php echo $secureid; ?>" name="secureid" />
<p>Please enter the security code you see: <?php echo $secureid; ?></p>
<input type="text" value="Code" name="securev" />
...
<input type="submit" value="Send" name="finished" />
</form>

and on Contact.php
Code:
<?php
if(isset($_POST['finished']))
{
$securityconf = $_POST['secureid'];
$securitycode = $_POST['securev'];
//if you're ever inserting raw post data into a database, make sure you use the escape string function, just a side note
if($securitycode == $securityconf)
{
//continue processing
}
else
{
header('Location /contact_error.php');
}
?>

Hope it works for you

EDIT: Whoops, I see you've accomplished this already redface.gif
Edited by ZFedora - 8/7/12 at 12:11am
Server
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2600k Intel H67DE PNY Verto 9600GT (Thanks to ihasfip!) 16GB G.Skill Ripjaws 1333Mhz 
Hard DriveOSMonitorPower
(3) Seagate 7200K 1TB (2) Hitachi 7200K.12 1TB Proxmox Samsung 17" Corsair GS600 
Case
Chenbro tower 
  hide details  
Reply
Server
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2600k Intel H67DE PNY Verto 9600GT (Thanks to ihasfip!) 16GB G.Skill Ripjaws 1333Mhz 
Hard DriveOSMonitorPower
(3) Seagate 7200K 1TB (2) Hitachi 7200K.12 1TB Proxmox Samsung 17" Corsair GS600 
Case
Chenbro tower 
  hide details  
Reply
post #33 of 38
Thread Starter 
I'm still stuck on what I'm dealing with on my last post before this one.
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
post #34 of 38
Thread Starter 
This is really proving to be more difficult than expected.
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
post #35 of 38
Thread Starter 
Any suggestions? I've done what I can, and now I'm at a total loss here without completely starting over and losing my site format.
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
post #36 of 38
Why not, on the submit, just send the current content of the fields via the URL. Set up some PHP variables so that the page refreshes with the error code, and also replaces the fields with the data from the previous page, by collecting the PHP variables from the URL.

Does that make sense? Its not too hard.
post #37 of 38
Thread Starter 
It makes sense, I understand what needs to be done. I just can't implement it right.
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
post #38 of 38
Thread Starter 
Many thanks to those who helped! I'm probably about 80% complete with the form and how I want it. Now I'm just doing some trial and error coding within the PHP to get it how I want.
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
The Vortex
(16 items)
 
The Beast
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-2600K @ 4.5ghz Asus P8P67 WS Revolution 2 x HIS IceQ HD 6970 2GB G.Skill Ripjaws X 16GB 2133MHZ 
Hard DriveOptical DriveCoolingOS
Crucial C300 SSD 128GB SATA III, WD Caviar Black ASUS DRW SATA 24X DVD Corsair H60 Windows 8 Enterprise 64-Bit 
MonitorMonitorMonitorKeyboard
Samsung SyncMaster SA550 Samsung SyncMaster SA550 Samsung SyncMaster SA550 Logitech G510 
PowerCaseMouse
Antec CP-1000 Antec Twelve Hundred ATX Full Tower Logitech G9x 
CPUMotherboardGraphicsRAM
Intel Core i7-960 Bloomfield ASUS P6X58D Sapphire Vapor-X HD5870 G.Skill Ripjaws 24GB 1600MHZ 
Hard DriveHard DriveOptical DriveOS
Intel 510 120GB SSD SATA III, WD Caviar Black 1TB Kingston SSDNow V+ Series SNVP325-S2B/64GB 2.5"... ASUS DRW SATA 24X DVD Burner Windows 7 Ultimate 64-Bit SP1 
PowerCase
Antec CP-1000 Antec Twelve Hundred ATX Full Tower 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › PHP Form data retention