Jump to content

stutego

Members
  • Posts

    23
  • Joined

  • Last visited

About stutego

  • Birthday 06/29/1990

Profile Information

  • Gender
    Male
  • Interests
    programming,soccer and reading
  • Age
    22

Contact Methods

  • Yahoo
    stainless818@yahoo.com

stutego's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. form not posting to database instead its redirecting me to another page with heading "object not found!" <?php $connect= mysql_connect("localhost", "username", "password"); if (!$connect) { die("could'nt connect to db:".mysql_error()); } mysql_select_db("myapp", $connect); $sql="INSERT INTO form(fname,lname,email,password,telephone,sex,dob) VALUES ('','$_POST[fname]', '$_POST[lname]', '$_POST[email]' '$_POST[password]', '$_POST[telephone]', '$_POST[sex]', '$_POST[dob]')"; if (!mysql_query($sql, $connect)) { die("Error:" .mysql_error()); } mysql_close($connect); function spamcheck($field) { $field = filter_var($field, FILTER_SANITIZE_EMAIL); if(filter_var ($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_POST['email'])) { $mailcheck = spamcheck($_POST['email']); } if($mailcheck == FALSE) { //echo "invalid input"; } else { $email=$_POST['email']; $fname=$_POST['fname']; $lname=$_POST['lname']; $password=$_POST['password']; $retype_password=$password; $telephone=$_POST['telephone']; $sex=$_POST['sex']; $DOB=$_POST['dob']; } function yearOptions() { for ($i = 1910; $i <= date('Y'); $i++) { $s = date('Y') == $i ? ' selected="selected"' : ''; echo '<option '.$s.' value="'.$i.'">'.$i.'</option>'."\n"; } } function monthOptions() { $months = array( 1 => "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); foreach ( $months as $monthNo => $month ) { ( $monthNo == date('n') ) ? $selected = ' selected="selected"' : $selected = ''; echo '<option value="'.$monthNo.'"'.$selected.'>'.$month.'</option>'."\n"; } } function dayOptions() { for ( $i = 1; $i <= 31; $i++ ) { ( $i == date('j') ) ? $selected = ' selected="selected"' : $selected = ''; echo '<option value="'.$i.'"'.$selected.'>'.$i.'</option>'."\n"; } } $password=$_POST["password"]; $salt=rand(100000,999999); $encrypted= (MD5(MD5($salt.$password))); if($retype_password!=$password) { echo "password mismatch"; } ?> <form action = "register.php" method=post> <fieldset> Firstname: <input type="text" size=30 name="fname"><br> Lastname: <input type="text" size=30 name="lname"><br> Email address: <input type=text size=30 name="email"><br> Password: <input type=password size=30 name="password"><br> Retype Password: <input type=password size=30 name="retype_password"><br> Telephone: <input type=tel size=30 name="telephone"><br> sex: <input type="radio" name="sex" value="male" checked="checked">Male<br/><input type="radio" name="sex" value="female">Female<br> Date of birth: <select name="dob"> <?php dayOptions();?> </select> <select name="dob"> <?php monthOptions();?> </select> <select name="dob"> <?php yearOptions();?> </select><br> <INPUT TYPE=SUBMIT VALUE="Register"> </fieldset> </form>
  2. please i've been trying to create a registration form for my website and it seems like its taking forever..... i've got some error of which i have tried to rectify but to no avail, so decided post the code and the error to see if someone might be of help to me <?php $required=array("fname" => "Firstname", "lname" => "Lastname", "email" => "Email address", "password" => "Password"); foreach ($required as $field => $label) { if (isset($_POST[$field])) { $warnings[$field] = "Required"; } } if (isset($_POST["email"])&& !ereg("^[^@]+@([a-z\-]+\.)+[a-z]{2,4}$", $_POST["email"])) $warnings["email"] = "Invalid email"; if (isset($_POST["telephone"])&& !ereg("^\([[:digit:]]{3}\)[[:digit:]]{4}-[[:digit:]]{4}$", $_POST["telephone"])) $warnings["telephone"] = "Must be (555)0000-0000"; $password=$_POST["password"]; $salt=rand(100000,999999); $encrypted= (md5($salt.$password)); if (empty($warnings) > 0) { ?> <form action = "register.php" method=post> <table border=0> <tr> <td>Firstname:</td> <td><input type=text size=30 name="fname" value="<?php echo (isset($_POST["fname"])? $_POST ["fname"]:"");?>" > </td> <td><?php echo (isset($warnings["fname"])? $warnings["fname"]:"");?> </td> </tr><br/> <tr> <td>Lastname:</td> <td><input type=text size=30 name="lname" value="<?php echo (isset($_POST["lname"])? $_POST ["lname"]:"");?>"> </td> <td><?php echo (isset($warnings["lname"])? $warnings["lname"]:"");?> </td> </tr> <tr> <td>Email address:</td> <td><input type=text size=30 name="email" <?php if (isset($warnings["email"])) echo "STYLE=\"shaded\"";?> value="<?php echo (isset($_POST["email"])? $_POST["email"]:"");?>"> </td> <td><?php echo (isset($warnings["email"])? $warnings["email"]:"");?> </td> </tr> <tr> <td>Password:</td> <td><input type=password size=30 name="password" value="<?php echo (isset($_POST["password"])? $_POST["password"]:"");?>"> </td> <td><?php echo (isset($warnings["password"])? $warnings[password]:"");?> </td> </tr> <tr> <td>Telephone:</td> <td><input type=text size=30 name="telephone" value="<?php echo (isset($_POST["telephone"])? $_POST["telephone"]:"")?>"> </td> <td><?php echo (isset($warning["telephone"])? $warnings["telephone"]:"");?> </td> </tr> <tr> <td>sex:</td> <td><?php include("sex.php"); ?> </td> <td></td> </tr> <tr> <td>Date of birth:</td> <?php $menu = generate_menu("year", $endYear = '', $startYear = '1900'); function generate_menu($name, $endYear = '', $startYear = '1900' ) { $selected = "<SELECT NAME=\"$name\">"; for ( $i = $startYear; $i <= $endYear; $i++ ) { $selected .= "<OPTION "; ( $i == date('Y') ) ? $selected .= "selected='selected'" : $selected = ''; $selected .= "value=\'$i\'>$i</OPTION>"; } $selected .= "</SELECT>"; return($selected); } ?> <? $month = array(1=> "Jan", 2=> "Feb", 3=> "Mar", 4=> "Apr", 5=> "May", 6=> "Jun", 7=> "Jul", 8=> "Aug", 9=> "Sep", 10=> "Oct", 11=> "Nov", 12=> "Dec"); $default = "1"; $option = generate_menu("month", $month, $default); function generate_menu($name, $month, $default="") { $select = "<SELECT NAME=\"$name\">"; foreach($month as $value => $label) { $select .= "<OPTION "; if ($value == $default) $select .= "selected='selected'"; $select .= "value=\'$value\'>$label</OPTION>"; } $select .= "</SELECT>"; return($select); } ?> <? $function = generate_menu("day"); function generate_menu($name) {$sel = "<SELECT NAME=\"$name\">"; for ( $i = 1; $i <= 31; $i++ ) { $sel .= "<OPTION "; ( $i == date('j') ) ? $sel .= "selected='selected'" : $sel = ''; $sel .= "value=\'$i\'>$i</OPTION>"; } $sel .= "</SELECT>"; return($sel); } ?> <td> <?php print $menu;?> </td> <td> <?php print $option;?> </td> <td> <?php print $function;?> </td> </tr> </TABLE> <INPUT TYPE=SUBMIT VALUE="Register"> </form> <?php } else { echo "Thank you for registering"; } ?> error Fatal error: Call to undefined function generate_menu() in C:\xampp\htdocs\form.php on line 65
  3. i need help on how to write a code or a clue on what i need to know when writting it
  4. somebody once told me in this forum that i can't create a good calculator with php, but i've been trying my best to prove the critics wrong, and in my effort to do so i have written a front view of how the calculator will look like but the problem is am new to php dont have an idea of how to extract the value from the clicking of a number and dont know how to go about with coding php this is the front view <table border ="5"> <table border="2"> <th><input type="text" name="num" size="23" ></th> </table> <table border="3"> <tr> <td><button size="0">+</button></td> <td><button width="0"> - </button></td> <td><button>*</button></td> <td><button>/</button></td> </tr> <tr> <td><button>-></button></td> <td><button>1</button></td> <td><button>2</button></td> <td><button>3</button></td> </tr> <tr> <td><button>4</button></td> <td><button>5</button></td> <td><button>6</button></td> <td><button>7</button></td> </tr> <tr> <td><button>8</button></td> <td><button>9</button></td> <td><button>0</button></td> <td><button>=</button></td> </tr> <tr> <td><button>.</button></td> <td><button>%</button></td> <td><button>^</button></td> <td><button>!</button></td> </tr> </table> </table> please help out
  5. never let a day pass by without learning a bit from it

  6. please friends i have been trying to fetch data from my database but my output is showing a blank page this are my codes ?php $host_name = "localhost"; $user_name = "root"; $password = ""; $db_name = "addressbook"; mysql_connect("$host_name", "$user_name", "$password"); mysql_select_db("$db_name"); $result = mysql_query("SELECT * FROM bestway"); ?> its just showing a blank page i cant tell why
  7. i've tried this $required=array("fname" => "Firstname", "lname" => "Lastname", "email" => "Email address", "password" => "Password"); foreach ($required as $field => $label) { if (isset($_POST[$field])) { $warnings[$field] = "Required"; } } and got another error message as this Notice: Undefined variable: warnings in C:\xampp\htdocs\form.php on line 21 and this is what that line 21 is saying if (count($warnings) > 0)
  8. so please friends how am i going to clear this errors or notices like i've said before am new to php and i dont really understand this error messages that was my reason for posting it here
  9. yes tanx very much u've helped me figure some, remaining this ones Notice: Undefined index: fname in C:\xampp\htdocs\form.php on line 8 Notice: Undefined index: lname in C:\xampp\htdocs\form.php on line 8 Notice: Undefined index: email in C:\xampp\htdocs\form.php on line 8 Notice: Undefined index: password in C:\xampp\htdocs\form.php on line 8
  10. i've tried my best to clear the error and on like i said before am new to php, and i've been trying my best to learn php on my own please help out
  11. please friends i have a problem trying to create a form for my web site please this is the code <?php $required=array("fname" => "Firstname", "lname" => "Lastname", "email" => "Email address", "password" => "Password"); foreach ($required as $field => $label) { if (!$_post[$field]) { $warnings[$field] = "Required"; } } if ($_POST["email"] && !ereg("^[^@]+@([a-z\-]+\.)+[a-z]{2,4}$", $_POST["email"])) $warnings["email"] = "Invalid email"; if ($_POST["telephone"] && !ereg("^\([[:digit:]]{3}\)[[:digit:]]{3}-[[:digit:]]{4}$", $_POST["telephone"])) $warnings["telephone"] = "Must be (555)555-5555"; if (count($warnings) > 0) { ?> <form action = "register.php" method=post> <table border=0> <tr> <td>Firstname:</td> <td><input type=text size=30 name="fname" value="<?php echo $_post ["fname"];?>" > </td> <td><?php echo $warnings["fname"];?> </td> </tr><br/> <tr> <td>Lastname:</td> <td><input type=text size=30 name="lname" value="<?php echo $_post ["lname"];?>"> </td> <td><?php echo $warnings["lname"];?> </td> </tr> <tr> <td>Email address:</td> <td><input type=text size=30 name="email" value="<?php echo $_post["email"];?>"> </td> <td><?php echo $warnings["email"];?> </td> </tr> <tr> <td>Password:</td> <td><input type=text size=30 name="password" value="<?php echo $_post["password"];?>"> </td> <td><?php echo $warnings["password"];?> </td> </tr> <tr> <td>Telephone:</td> <td><input type=text size=30 name="telephone" value="<?php echo $_post["telephone"]?>"> </td> <td><?php echo $warnings["telephone"];?> </td> </tr> <tr> <td>Sex</td> <td><script src="sex.php"> </script></td> </tr> <tr> </TABLE> <INPUT TYPE=SUBMIT VALUE="Register"> </form> <?php } else { echo "Thank you for registering"; } ?> and this are the error messages, am a newbie to php please help and this is the error message Notice: Undefined variable: _post in C:\xampp\htdocs\form.php on line 8 Notice: Undefined variable: _post in C:\xampp\htdocs\form.php on line 8 Notice: Undefined variable: _post in C:\xampp\htdocs\form.php on line 8 Notice: Undefined variable: _post in C:\xampp\htdocs\form.php on line 8 Notice: Undefined index: email in C:\xampp\htdocs\form.php on line 13 Notice: Undefined index: telephone in C:\xampp\htdocs\form.php on line 16 please help me out
×
×
  • 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.