I am trying to follow this link and put all the code in a CEWP as suggested. After saving the page the code goes away (except for the gear part, top line).
I could really use some help if possible.
I'm sorry if I'm stating the obvious here... but you are clicking the Source Editor button and not the Rich Text Editor button when editing the Web part aren't you?
Another option is to eliminate the CEWP and instead edit the Page Layout file in SharePoint Designer and insert your code there.
The safest and easiest way to do this is to not save the code directly in the web part. The CEWP is trying to be clever and strips tags out because it sees it as potentially dangerous. Rather do this:
Save and you're done.
Instead of the CEWP try it with the Simple Form WebPart instead.