Jump to content

akrohn

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

akrohn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Great. Thanks for the help, I appreciate it.
  2. I'd like to develop a stand-alone app. So I'm willing to learn something new. I know this is not an app forum, so I don't want to go too deep into that. Can I use objective-c and java to query the db?
  3. If any of you have developed mobile apps before I could really use some advice, please. I have never made one, and would like to for my website. I just need to query my database and display the information. From what I have been able to put together so far, I know that I can use css and jquery fine. My main question is: can I use php to query the mysql database? Pretty much I am a novice, so if using these languages together will not work, please feel free to suggest combinations that would be better. Although, I am trying to avoid as much object oriented stuff as I can, because I just don't get it entirely, but I'll still take the suggestion. Thanks.
  4. I am sending a email verification that a person registers on my site. I have two problems. Here is the email script: $message = "Thank you for registering."; mail($email, 'Registration Confirmation', $message, 'From: noreply@website.com'); Problem 1: I have tried this on two different identical pages, index.php and register.php. It only works in the index page. Problem 2: When it does work on the index page, the From header does not show what is in the mail() function, it shows that it is from my host. What's up with that? Given the choice, I need to get problem 2 solved way more than problem 1. Thank you.
  5. OK. I have really learned a lot from this back and forth. Seriously, thanks for the people who have made me think about this problem. I added the mysql_error() right after the query, and what to my surprise, but the error was that I had not given that database user permission to SELECT. AAAHHHHH! Problem Solved! Thanks again.
  6. Isn't the conditional part what I am doing with this: if ($rows_1 >= 1) //If >= 1, email is already registered. Create error. { $error_email_taken = "This email is already registered."; } else { $e = $_POST['email']; }
  7. Ok. I have applied the error checking that you suggested. The error after form is submitted is: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource. This is in the line of the first query: $rows_1 = mysql_num_rows($r_1);
  8. xyph, could you help me understand how to apply the error checking? I really don't know where to begin with that.
  9. OK. I have worked some of the issues out. Here is my new email validation code. It now will insert the information into the database, and will redirect to the new page. But it seems to not check against existing emails in the database. Here it is: <?php if($_POST['Submit']) { //check to see email was submitted. If yes, check to see if email is registered. $username="username"; $password="password"; $database="database"; $dbc=mysql_connect ("localhost", $username, $password) or die ('Could not connect:'); mysql_select_db ("$database"); $email_check = $_POST['email']; $q_1 = "SELECT * FROM table WHERE users_email = $email_check"; $r_1 = mysql_query($q_1); $rows_1 = mysql_num_rows($r_1); if ($rows_1 >= 1) //If >= 1, email is already registered. Create error. { $error_email_taken = "This email is already registered."; } else { //assign email variable $e = $_POST['email']; } //If everything is good, insert the information. if(isset($e)) { $fn = $_POST['first']; $ln = $_POST['last']; $p = $_POST['pass']; //Insert User information. $q_2 = "INSERT INTO table (user_email, user_first, user_last, user_password) VALUES ('$e', '$fn', '$ln', '$p')"; mysql_query($q_2); //close the connection mysql_close(); //Go to registration submitted page. header('Location: http://www.newpage.php'); }//End: if($e) } //End: if $_POST['submit'] ?> So what this does now is it will insert the information into the database, regardless of an existing email, and then it does redirect to the new page. But I think it has to be running through that first query and checking for an existing email, because it seems that it must be assigning the variable $e to $_POST['email'], because the next thing is to check for that varible ($e) in order to execute the INSERT, and the INSERT is happening. So I am not receiving any errors, but really, I'm not sure how to write that into the code so that it stops where the error may be occuring. Also, when I assign the variable $error_email_taken, does that make sense to anyone else how I want that to work, where if there is an existing email in the database, the variable is created then the script does not continue, and the form is shown again, with that variable showing the error in the form? Maybe one of my mistakes is that it can't work that way. Thanks.
  10. I have made a form that asks a user for email, first name, last name, and password. I am using Spry validation tools in Dreamweaver. When I used those only, I did not have a problem. The problem began once I tried to actually check to see if the email was already registered. I have tried changing so many things like what $_POST variable to look for at the beginning, to different db connection arrangements. I am stumped. The only other thing I can think of is that I have the order wrong somehow in the logic. Thanks for the help. First, here is the form: Enter Email<?php if($error_email_taken) echo ": $error_email_taken."; ?> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="email" type="text" id="email" value="<?php if($_POST["email"]) echo $_POST["email"]; ?>"> <input name="first" type="text" id="first" value="<?php if($_POST["first"]) echo $_POST["first"]; ?>"> <input name="last" type="text" id="last" value="<?php if($_POST["last"]) echo $_POST["last"]; ?>"> <input name="pass" type="password" class="formText1" id="pass" value="<?php if($_POST["pass"]) echo $_POST["pass"]; ?>"> <input type="submit" name="Submit" value="Submit"></td> </form> And the email verification and insert, which is placed before the opening html tag. <?php if($_POST['Submit']) { //Check to see if email is registered. $email = $_POST['email']; $dbc=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $q_1 = "SELECT users_email FROM table WHERE users_email = $email"; $r_1 = mysqli_query($dbc, $q_1); $rows_1 = mysqli_num_rows($r_1); if ($rows_1 == 0) { //If 0, email is not already registered. $new_email = $_POST['email']; } else { $error_email_taken = "This email is already registered."; } //If everything is good, insert the information. if(isset($new_email)) { $first_name = $_POST['first']; $last_name = $_POST['last']; $password = $_POST['pass']; //Insert User information. $q_2 = "INSERT INTO table (users_email, users_first, users_last, users_pass) VALUES ('$new_email', '$first_name', '$last_name', '$password')"; $r_2 = mysqli_query($dbc, $q_2); //Go to new page if form was submitted and information properly inserted. header('Location: new_page.php'); }//End: if($new_email) } //End: if $_POST['submit'] ?> I've simplified it as much as I could. I totally eliminated stuff like a password hash, etc. because I wanted to get it down to the most simple form, so once this gets working, I'll add that other stuff later. Thanks so much again.
  11. I would like to have my site automatically email me about progress of users at certain times of the day. I am using PHP, but I think this is a server issue. I just need someone to point me in the right direction so I can search out the solution. Thank you.
  12. In a form example I am learning from I came across the value of the submit button being 'Next &rarr'. Could anyone explain this to me rather than using a value that sends you to another page to process the form? In this example what I am trying to learn is form validation using a function that checks for letters and numbers only.
  13. When a site like facebook asks you if you want to import your email contacts, like from yahoo, how do they do that? Is there a script in PHP that can be used for this? Thank you.
  14. Oh, you bastards. It was my password. Only, I had it wrong when I set up the user for the database, rather than the one that I was using in my script. Thanks so much for your help, and sorry for taking up so much of your time.
×
×
  • 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.