Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 PHP POST_Registration forum error
Index -> Web Design
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
QuantumPhysics




PostPosted: Mon Feb 04, 2013 10:12 pm   Post subject: PHP POST_Registration forum error

Here is my code in HTML/PHP:

HTML:

<?PHP
require_once("./include/membersite_config.php");

if(isset($_POST['submitted']))
{
   if($fgmembersite->
RegisterUser())
   {
        $fgmembersite->RedirectToURL("thank-you.html");
   }
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    <title>Contact us</title>
    <link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css" />
    <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
    <link rel="STYLESHEET" type="text/css" href="style/pwdwidget.css" />
    <script src="scripts/pwdwidget.js" type="text/javascript"></script>     
</head>
<body>

<!-- Form Code Start -->
<div id='fg_membersite'>
<form id='register' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-

charset='UTF-8'>
<fieldset >
<legend>Register</legend>

<input type='hidden' name='submitted' id='submitted' value='1'/>

<div class='short_explanation'>* required fields</div>
<input type='text'  class='spmhidip' name='<?php echo $fgmembersite->
GetSpamTrapInputName(); ?>' />

<div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div>
<div class='container'>
    <label for='name' >Your Full Name*: </label><br/>
    <input type='text' name='name' id='name' value='<?php echo $fgmembersite->SafeDisplay('name') ?>'

maxlength="50" /><br/>
    <span id='register_name_errorloc' class='error'></span>
</div>
<div class='container'>
    <label for='email' >Email Address*:</label><br/>
    <input type='text' name='email' id='email' value='<?php echo $fgmembersite->
SafeDisplay('email') ?>'

maxlength="50" /><br/>
    <span id='register_email_errorloc' class='error'></span>
</div>
<div class='container'>
    <label for='username' >UserName*:</label><br/>
    <input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay

('username') ?>' maxlength="50" /><br/>
    <span id='register_username_errorloc' class='error'></span>
</div>
<div class='container' style='height:80px;'>
    <label for='password' >Password*:</label><br/>
    <div class='pwdwidgetdiv' id='thepwddiv' ></div>
    <noscript>
    <input type='password' name='password' id='password' maxlength="50" />
    </noscript>   
    <div id='register_password_errorloc' class='error' style='clear:both'></div>
</div>

<div class='container'>
    <input type='submit' name='Submit' value='Submit' />
</div>

</fieldset>
</form>

<script type='text/javascript'>
// <![CDATA[
    var pwdwidget = new PasswordWidget('
thepwddiv','password');
    pwdwidget.MakePWDWidget();
   
    var frmvalidator  = new Validator("register");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
    frmvalidator.addValidation("name","req","Please provide your name");

    frmvalidator.addValidation("email","req","Please provide your email address");

    frmvalidator.addValidation("email","email","Please provide a valid email address");

    frmvalidator.addValidation("username","req","Please provide a username");
   
    frmvalidator.addValidation("password","req","Please provide a password");

// ]]>

</script>

</body>
</html>
 


When I link the page it outputs my entire form except the php setup does not work. It actually outputs the values in php onto the screen instead of linking the value to my other get files (simply look at the value='<?php>') in the form when I submit the form.
Sponsor
Sponsor
Sponsor
sponsor
QuantumPhysics




PostPosted: Tue Feb 05, 2013 2:28 am   Post subject: RE:PHP POST_Registration forum error

Update... the <?php?> tags just dont work and I don't know why... for example when I run this code here that I took from wikihow...
<?php
if (isset($_POST['submit'])) {
}
if (!empty($_POST['firstname'])) {
$firstname = $_POST['firstname'];
} else {
$firstname = FALSE;
echo "<p><font color='red'>Please enter your first name!

</font></p>";
}
Type the following to validate the 'lastname' text box:
if (!empty($_POST['lastname'])) {
$lastname = $_POST['lastname'];
} else {
$lastname = FALSE;
echo "<p><font color='red'>Please enter your last name!

</font></p>";
}
if (!empty($_POST['email'])) {
$email = $_POST[' email '];
} else {
$email = FALSE;
echo "<p><font color='red'>Please enter your email address!

</font></p>";
}
if ($firstname != FALSE && $lastname != FALSE && $email != FALSE) {
$to = $email;
$subject = "Thank you for becoming a member of 'www.test.com'!"
$body = "<html><head></head><body>Thank you for joining

'yoursite.com'!<br /><br />We have the following details that you

submitted:<br /><br />First Name: " . $firstname . "<br

/>Last Name: " . $lastname . "<br />Email Address: "

. $email . "<br /><br />We welcome you to your team! Please contact

us if this information is inaccurate.<br /><br />Thanks you, <br

/><br /> Site Owner<br />email address</body></html>";
$headers = "MIME-Version: 1.0\n" . "Content-type: text/html;

charset=iso-8859-1\n" .
"From: Your Company[donotreply@yourdomain.com]\n" . "Cc: Your Name

[youremail@yourdomain.com]\n";
mail($to,$subject,$body,$headers);
echo "<p><font color='navy'>Your information has been sent to the

owner of the website! You should be receiving an email shortly!

</font></p>";
} else {
echo "<p><font color='red'>The email could not be sent due to an

error. See above.
</font></p>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
First Name:<br />
<input type="text" name="firstname" size="60" /><br /><br />
Last Name:<br />
<input type="text" name="lastname" size="60" /><br /><br />
Email Address:<br />
<input type="text" name="email" size="60" /><br /><br />
<input type="submit" value="Submit" name="submit" />
</form>
</body>
</html>

Still doesnt work, even a pre-executed version doesnt work. That's how I know my code didn't have any errors. This is the output of my screen.

Posted Image, might have been reduced in size. Click Image to view fullscreen.
2goto1




PostPosted: Tue Feb 05, 2013 8:49 am   Post subject: RE:PHP POST_Registration forum error

You don't have PHP configured within your web server (should be IIS in your case). You need to ensure PHP is installed and configured on your web server.

Right now your web server doesn't recognize the .php file extension, so it is serving those files with its static file handler module. That's why you're seeing the PHP source getting returned to your browser.

See http://php.iis.net/ or http://php.net/manual/en/install.windows.iis7.php
DemonWasp




PostPosted: Tue Feb 05, 2013 10:00 am   Post subject: RE:PHP POST_Registration forum error

Err, he's not even using a webserver, as far as I can tell. He's just displaying the raw .php file in his browser.

You need to install a PHP-capable webserver. I'd recommend Apache's httpd, because that's what most of the world uses, but I suppose you could also use IIS or nearly any other web server.
2goto1




PostPosted: Tue Feb 05, 2013 1:04 pm   Post subject: RE:PHP POST_Registration forum error

Whoops, didn't look at the file:// protocol in his browser.

Right, providing you have a web server installed on your local development machine, your links to your PHP files will then look like http://localhost/etc/etc/.

You may want to choose your web server based on the "live website" server that your website will eventually run on. Sometimes you're stuck with the web server IIS, sometimes you're stuck with the web server Apache, unless you have full control over your server OS and what web server will be used on your server...at which point Apache would probably be the way to go for your own personal benefit!
QuantumPhysics




PostPosted: Wed Feb 06, 2013 8:45 pm   Post subject: RE:PHP POST_Registration forum error

Okay I set up an apache web server with PHP5.2.17 and MYSQL5.1.68

I am now able to run PHP files with no errors on there own. I am very happy about this. But right now I tried to run a php script on an html file (I am trying to add a login (i made a php script for it)) when I load the index.html page it gives me this at the top:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

I find this very strange because I set up the Apache web server, everything was working until i put a php script in html. I even added an .htaccess file to my htdocs file in the apache foundations folder (the apache webserver document root).

The .htaccess file reads as follows:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Thank you for any advice or tips. I really need to solve this, and fast!

Sincerly,
~QP
Sur_real




PostPosted: Wed Feb 06, 2013 10:11 pm   Post subject: RE:PHP POST_Registration forum error

What do you mean by 'php script on an html file', is the page you have an php file? only files with extension .php are executed on a php server.
QuantumPhysics




PostPosted: Thu Feb 07, 2013 12:37 am   Post subject: RE:PHP POST_Registration forum error

I have php tags inside an .html file, but I need to keep it html because its my index file and the login part to contact the database is coded in PHP...

<html>
<head>
<body>
<h1>This is the index page, please login below</h1>
// after credentials entered, check if valid... and connect to mysql database to send out email verification to user
<?PHP
// PHP script to do so...
?>
</body>
</head>
</html>

I need for it to read the PHP properly without just outputting it on the screen like the picture above... and read the HTML to output the actual page layout, javascript, and text(s) at the same time.
DemonWasp




PostPosted: Thu Feb 07, 2013 8:17 am   Post subject: RE:PHP POST_Registration forum error

You don't need to name it index.html; the choice of name for the webserver index file is determined by webserver settings. This Wiki article has a good intro: http://en.wikipedia.org/wiki/Webserver_directory_index
QuantumPhysics




PostPosted: Thu Feb 07, 2013 8:47 am   Post subject: RE:PHP POST_Registration forum error

I changed the document root to php but it doesn't load up index.php when i open up the server (ip). It just takes me to the parent directory of all files
DemonWasp




PostPosted: Thu Feb 07, 2013 10:26 am   Post subject: RE:PHP POST_Registration forum error

That Wikipedia page I linked wrote:
...Apache, where the list of filenames is controlled by the DirectoryIndex directive in the main server configuration file or in the configuration file for that directory.


The link goes to: http://httpd.apache.org/docs/2.0/mod/mod_dir.html#directoryindex , which tells you exactly how to make httpd respond to directory requests with index.php .
QuantumPhysics




PostPosted: Thu Feb 07, 2013 4:23 pm   Post subject: RE:PHP POST_Registration forum error

DirectoryIndex index.php
I set that up in my config and it just directs me to the parent database where you see all the folders on your server but the actual index doesnt open up.
Display posts from previous:   
   Index -> Web Design
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: